服务android在特定手机启动时不启动

时间:2016-03-15 14:23:28

标签: android service boot

我已经创建了一项服务,它在三星设备上运行正常,但在手机启动时阿尔卡特手机无法启动,我的清单代码在下面

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.app.app"
android:versionCode="1"
android:versionName="Version">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.QUICKBOOT_POWERON" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />

<application android:name="com.redcentral.redcentral.AnalyticsApplication"
    android:allowBackup="true"
    android:icon="@mipmap/icon_app"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <receiver
        android:name="com.app.app.ScheduleReceiver"
        android:enabled="true"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        </intent-filter>
    </receiver>
    <service android:name="com.app.app.NotificationService" android:enabled="true"></service>

    <activity
        android:name="com.app.app.Login"
        android:label="@string/app_name"
        android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|uiMode"
        android:screenOrientation="portrait"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.app.app.MainActivity"></activity>

</application>

有什么问题或者我需要在手机启动时添加什么才能启动?

这是我的ScheduleReceiver代码

public class ScheduleReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

    /***** For start Service  ****/
        Intent myIntent = new Intent(context, NotificationService.class);
        context.startService(myIntent);
}

1 个答案:

答案 0 :(得分:0)

您的代码看起来不错,AFAIK有些设备在其设置中有Statup Manager menu,因此请确保您Alcatel选中了该选项,同时检查您的Settings是否; Power&gt; Fast Boot启用或禁用,应该启用。