如何在引导时启动的Andr​​oid /启动应用程序 [英] How to start/ launch application at boot time Android

查看:119
本文介绍了如何在引导时启动的Andr​​oid /启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要发动我的应用我的平板电脑开始的时候,让我的应用程序的主要活动是,当他们开始在平板电脑用户看到的第一件事。
我读过有关LauncherActivity,但我不知道如何使用它。
谁能帮我提供建议,链接或教程吗?
是LauncherActivity最好的办法还是有办法?

I would like to launch my app when my tablet starts, so that the main activity of my app is the first thing that the user see when they start the tablet.
I've read about LauncherActivity but I don't understand how to use it.
Can anyone help me with suggestions, links or tutorials for this?
Is LauncherActivity the best way or are there alternatives?

推荐答案

这些线code你...

These line of code maybe helpful for you...

第一步: 设置权限在AndroidManifest.xml中

Step1: set the permission in AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

第二步: 添加这是在接收器意图过滤器,

Step2: Add this is intent filter in receiver,

<receiver android:name=".BootReciever">
    <intent-filter >
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>

第三步: 现在,你可以从接收器类的onReceive方法启动应用程序的第一个活动。

Step3: Now you can start your application's first activity from onReceive method of Receiver class..

public class BootReciever extends BroadcastReceiver
{

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Intent myIntent = new Intent(context, Tabs.class);
    myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(myIntent);
}

}

这篇关于如何在引导时启动的Andr​​oid /启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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