我正在开发widget项目,当我触摸窗口小部件时,一个新的活动就像一个对话框样式。将打开主活动并显示对话框样式活动,当我触摸主活动时,对话框样式活动将消失。 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);
}
}
Dialog Styled Actvity
<?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>
提前致谢。
答案 0 :(得分:0)
如果其他人有兴趣我使用此行
this.setFinishOnTouchOutside(false);