当Android手机处于开机状态如何自动劳克的第3应用程序 [英] how to lauch an 3rd application automatically when the android phone is switched on

查看:152
本文介绍了当Android手机处于开机状态如何自动劳克的第3应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果
任何一个可以告诉我,怎么当的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 >

这篇关于当Android手机处于开机状态如何自动劳克的第3应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆