【问题标题】:my application not start on BootUp mobile [duplicate]我的应用程序无法在 BootUp 移动设备上启动 [重复]
【发布时间】:2013-06-18 12:25:32
【问题描述】:

这是我的应用程序下方的清单文件当我打开手机时没有启动我的应用程序我像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);
    }
}

【问题讨论】:

  • 请不要发布重复的问题
  • @lovelyguy - 运气好吗?

标签: android


【解决方案1】:

检查我的这个问题,以及提供的答案 - 它们是相关的,并且可能会解决您的问题:

尽管使用的意图不同,但我在下面描述的安全问题是相似的。


问题可能是您需要在应用程序响应BOOT_COMPLETED 意图之前运行一次。

这是一项安全措施。

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

  1. 编写应用程序
  2. 安装应用程序
  3. 运行应用程序
  4. 重启手机看看是否正常

【讨论】:

  • 我想在手机重启或开机时启动我的应用程序
  • 您的代码看起来不错,快速浏览一下。这是新开发人员的常见问题 - 应用程序需要在安装后运行一次......然后它将监听 BOOT_COMPLETED 意图。
  • 我的应用将运行我会检查它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-04
  • 2020-02-06
  • 2019-11-03
相关资源
最近更新 更多