我的应用程序作为启动器工作,并且它在启动时启动。但是,它有些问题。例如,我在设备上安装我的应用程序,并通过选择Always按钮(作为默认启动器)打开它。这里没有问题。但是,如果我重新启动设备(它在启动时打开,如前所述),应用程序将打开。但是当我想关闭它时,我无法做到这一点。它再次打开。
这是我的清单文件:
启动后我无法关闭我的启动器应用程序
<receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity
android:name="com.comeks.cocuktablet.Main"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这是BootUpReceiver.java:
public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
Intent i = new Intent(context, Main.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
你昨天基本上问了同样的问题。 http://stackoverflow.com/questions/15885626/how-to-end-a-launcher-completely并禁用启动器功能,用户将不得不去设置 - >管理应用程序 - >你的应用程序 - >清除默认值。他们按下清除默认按钮后,他们会按下主页按钮,他们会得到弹出显示所有avaialbe发射器,包括股票之一(和你的) – FoamyGuy 2013-04-09 14:40:35
@Arju谢谢你的回答。我尝试过,但是当我在意图过滤器中删除这4行中的一行时,它不起作用。 – halilkaya 2013-04-09 14:43:32