小编Jam*_*ner的帖子

基于Android示例的颤振应用程序在BOOT_COMPLETED上自动启动不起作用

有很多使用 BOOT_COMPLETED 在设备启动时启动应用程序的示例。我尝试将这些示例用于我的 Flutter 应用程序。让它启动应用程序。这是用于显示图像的简单标牌应用程序。基本上类似于相框。

在下面的示例代码中,应用程序正在编译,但是,例如,当我重新启动模拟器时,代码似乎没有任何效果。

我的猜测是我没有调用正确的代码来实际启动应用程序。清单如下..

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="au.net.digitall.cmplayer">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="cm_player"
    android:icon="@mipmap/ic_launcher"
    tools:ignore="GoogleAppIndexingWarning">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/cmTheme2"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">

        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true" />
        <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=".StartCmPlayerServiceAtBootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
</application>
Run Code Online (Sandbox Code Playgroud)

然后StartCmPlayerServiceAtBootReceiver类启动APP..

package au.net.digitall.cmplayer;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;


public class StartCmPlayerServiceAtBootReceiver extends BroadcastReceiver {

    private static final String TAG = StartCmPlayerServiceAtBootReceiver.class.getSimpleName();

    @Override
    public void …
Run Code Online (Sandbox Code Playgroud)

android startup dart flutter

5
推荐指数
1
解决办法
4747
查看次数

标签 统计

android ×1

dart ×1

flutter ×1

startup ×1