1
我有一個應用程序,我開始它遠程與broadcast receiver
。 我用這個方法從應用程序的抽屜隱藏:應用程序沒有啓動後隱藏它從應用程序抽屜上android
public static void hideFromAppDrawer(Context c) {
ComponentName componentToDisable = new ComponentName(
"mypackage", "mypackage.MyMainActivity");
c.getPackageManager().setComponentEnabledSetting(componentToDisable,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
但隱藏後,(我牆根的laucher活動,之後我想遠程啓動同一活動)的應用程序不會啓動。日誌說:
03-27 15:00:53.494: E/AndroidRuntime(23392): FATAL EXCEPTION: main
03-27 15:00:53.494: E/AndroidRuntime(23392): java.lang.RuntimeException: Unable to start receiver mypackage.receivers.myReceiver: android.content.ActivityNotFoundException: Unable to find explicit activity class {mypackage/mypackage.MyMainActivity}; have you declared this activity in your AndroidManifest.xml?
03-27 15:00:53.494: E/AndroidRuntime(23392): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
的錯誤是在broadcast receiver's
onReceive()
方法時我試圖啓動活動:
context.startActivity(i);
03-27 15:00:53.494: E/AndroidRuntime(23392): at ... .onReceive(MyReceiver.java:36)
可能是什麼問題,我如何能夠啓動我的應用程序,同時它是從應用程序抽屜中隱藏?
簡單而棒!感謝你及時的答覆!首先,我得到一個錯誤,因爲我把「別名活動」放在真正的「別名」之前,現在很好。 – keybee 2013-03-27 15:00:50