【发布时间】:2014-02-02 17:17:02
【问题描述】:
我正在处理小部件项目,当我触摸小部件时,会出现一个样式类似于对话框的新活动。主活动打开,对话框样式的活动出现,当我触摸主活动时,对话框样式的活动消失。 1)有没有办法禁用活动?要么 2)是否可以在不打开活动的情况下打开对话框样式的活动?
这是我的 BroadcastReceiver 中的 onReceive 类
public void onReceive(Context context, Intent intent)
{
Log.i(TAG,"In onReceive");
if(intent.getAction().equals(INTENT_ACTION))
{
Intent mIntent = new Intent(context,sendActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mIntent);
}
}
对话框样式的活动
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/tvdialogTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:layout_toRightOf="@+id/image"/>
<TextView
android:id="@+id/tvStatus01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF" />
<TextView
android:id="@+id/tvStatus02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"/>
<Button
android:id="@+id/btnWidgetDialogCancel"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_below="@+id/image"
/>
</RelativeLayout>
我的清单的一部分
<activity
android:name="com.example.widget.sendActivity"
android:theme="@android:style/Theme.Dialog"
android:excludeFromRecents="true">
</activity>
提前致谢。
【问题讨论】:
标签: android android-activity dialog widget