2012-04-17 72 views
6

我做了一个android应用程序,启动完成后立即启动。它在Android 2.3.3和Android 3.1的作品,但当我强制关闭应用程序在Android 3.1中运行,我再次重新启动后,应用程序不会来启动后?刚刚启动后的Android应用程序

+0

是的,它不会在3.1 [检查这个主题](http://stackoverflow.com/questions/8531926/how-to-start-a-service-when-apk-is-installed-for-the - 第一次) – 2012-04-17 11:17:07

回答

2

当我强制关闭应用程序在Android 3.1中运行,我再次重新启动应用程序不会在开机后来?

正确。在Android 3.1+,以下类型的应用程序不会自动运行:被新安装的用户具有

  • 应用

    • 应用“力停止”

    这些应用程序必须先手动是由用户开始(例如,启动您的一项活动),然后再次收到任何广播Intents

  • 2

    我与此代码做到这一点,它为我工作:

    public class AutoStarter extends BroadcastReceiver { 
        public void onReceive(Context context, Intent intent) 
        { 
         if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) 
         { 
         Intent serviceLauncher = new Intent(context, your.class); 
         context.startService(serviceLauncher); 
         } 
        } 
    } 
    

    测试你可以在你的CMD使用

    亚行外壳AM广播-a android.intent.action.BOOT_COMPLETED

    +0

    谢谢Boe ..我也diid相同类型的代码,但问题是不同的........ – 2012-04-17 09:56:01

    相关问题