2013-06-18 49 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

我的應用程序將運行,我會檢查它 –

相關問題