当Android手机处于开机状态如何自动劳克的第3应用程序应用程序、状态、手机、Android

由网友(老衲戒女神)分享简介:结果任何一个可以告诉我,怎么当的Andr​​oid手机开机自动劳克的第3应用程序?。当我要启动这是我写的,当设备被打开的应用程序。结果我会等待任何有价值的回复。在预先感谢can any one tell me "how to lauch an 3rd application automatically when the...

结果任何一个可以告诉我,怎么当的Andr​​oid手机开机自动劳克的第3应用程序?。当我要启动这是我写的,当设备被打开的应用程序。结果我会等待任何有价值的回复。

在预先感谢

can any one tell me "how to lauch an 3rd application automatically when the android phone is switched on?". As I want to launch an application which is written by me when the device is turned on. I will be waiting for any valuable reply .

Thanks in Advance,

推荐答案

您需要的 广播接收器 ,其目的是在 BOOT_COMPLETED 的行动。像这样的:

you need an implementation of BroadcastReceiver, which is intended on BOOT_COMPLETED action. Like this:

public class OnStartReceiver extends BroadcastReceiver {


  @Override
  public void onReceive(Context context, Intent intent) {
     Runtime.getRuntime().exec("your command");
     // but it is better here to do that:
     Intent myIntent = new Intent(context, YourActivity.class);
     context.startActivity(myIntent);
  }

}

此外,你应该添加 接收 标记到你的清单文件与的android:OnStartReceiver的名称 =您的全名和嵌套的 BOOT_COMPLETED 为目的的名字,像这样的:

Also, you should add receiver tag to your manifest file with android:name = your fully qualified name of OnStartReceiver and intent-filter tag nested with BOOT_COMPLETED as intent name, like this:

    <receiver android:name=".onStartReceiver">
       <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED"/>                    
       </intent-filter>
   </receiver >
阅读全文

相关推荐

最新文章