2013-06-18 199 views
0

这是我下面的应用程序时,我打开手机我按照这个喜欢how to start my application when ever mobile restart or turn on我的应用程序在启动时不启动移动

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.installedapps22" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="8" />  
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 
<application android:icon="@drawable/cherry_icon" android:label="@string/app_name"> 
    <activity android:name=".MainActivity" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity>   
    <receiver android:enabled="true" android:name="com.app.reciever.BootUpReciever"> 
    <intent-filter> 
     <action android:name="android.intent.action.BOOT_COMPLETED" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
    </intent-filter> 
</receiver> 
    <activity android:name=".ListInstalledApps" > </activity> 
    <activity android:name=".TabsLayoutActivity" /> 
    </application> 
</manifest> 

类文件

package com.example.installedapps22; 

public class BootUpReciever extends BroadcastReceiver 
{ 

    @Override 
    public void onReceive(final Context context, Intent intent) { 
     Intent i = new Intent(context, MainActivity.class); 
     i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     context.startActivity(i); 
    } 
} 
+3

请不要发布重复的问题 –

+0

@lovelyguy - 任何运气好吗? –

回答

0

检查这个无法启动我的应用我的manifiest文件我的问题和提供的答案 - 他们是相关的,并且可能会解决您的问题:

即使使用的意图不同,我在下面描述的安全问题是类似的。


的问题可能是你需要运行一次应用程序的时候,才到BOOT_COMPLETED意图做出回应。

这是一项安全措施。

如果您不运行应用程序,它将不会在启动时启动。试一试。

  1. 写应用
  2. 安装应用
  3. RUN APP
  4. 重启手机,检查是否正常工作
+0

我想在启动手机时启动我的应用程序或打开电话 –

+0

快速浏览一下,您的代码看起来没问题。对于新开发人员来说,这是一个常见的问题 - 应用程序需要在安装时运行一次......然后它将监听“BOOT_COMPLETED”意图。 –

+0

我的应用程序将运行,我会检查它 –

相关问题