重新启动平板电脑后,活动无法从广播接收器打开

时间:2016-12-28 11:52:33

标签: android android-activity broadcast

我的代码在app运行案例中工作,但重启设备后代码无效,广播是一个启动广播。

public class AlarmReceiver extends BroadcastReceiver {

    private ArrayList<UserVo> users;
    private int userCount;

    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "alarm start", Toast.LENGTH_LONG).show();
        Toast.makeText(context, "Alarm Triggered and SMS Sent", Toast.LENGTH_LONG).show();
        PrintUtil.printLog("Alarm Triggered", "");
        Intent intentone = new Intent(context, WelcomeActivity.class);
        // intentone.setClassName("appstute.in.smarttab", "appstute.in.smarttab.welcomeScreen");
        intentone.putExtra("userFlag", true);
        intentone.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.getApplicationContext().startActivity(intentone);
        //startActivity();
    }
}

我的清单,在这个清单中,我还添加了启动接收器,但仍然看不到我的活动。

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>`enter code here`
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="com.truiton.mapfragment.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
    <uses-permission android:name="android.permission.SEND_SMS" />

    <uses-feature android:name="android.permission.CALL_PHONE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
        android:persistent="true">
        <receiver
            android:name=".BootUpReceiver"
            android:enabled="true"
            android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>
        <receiver android:name=".AlarmReceiver" />

        <service android:enabled="true" android:name=".Service.AlarmService" />
        <service android:name=".location.LocationService" />
        <service android:name=".Service.WebService" />

        <activity
            android:name=".welcomeScreen.WelcomeActivity"
            android:noHistory="true"
            android:screenOrientation="portrait"
            android:alwaysRetainTaskState="true" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/. 
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity android:name=".feedbackQuestions.VodaFoneFeedbackActivity"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
        </activity>
        <activity android:name=".feedbackQuestions.StandardFeedbackFormActivity"
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
            android:screenOrientation="portrait">
        </activity>
    </application>

0 个答案:

没有答案