如何在引导时启动的Andr​​oid /启动应用程序应用程序、如何在、Andr、oid

由网友(网名够不够低调)分享简介:我要发动我的应用我的平板电脑开始的时候,让我的应用程序的主要活动是,当他们开始在平板电脑用户看到的第一件事。我读过有关LauncherActivity,但我不知道如何使用它。谁能帮我提供建议,链接或教程吗?是LauncherActivity最好的办法还是有办法?I would like to launch my...

我要发动我的应用我的平板电脑开始的时候,让我的应用程序的主要活动是,当他们开始在平板电脑用户看到的第一件事。 我读过有关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);
}

}
阅读全文

相关推荐

最新文章