相关疑难解决方法(0)

在Android中使用新的"manifestmerger"属性

在最新版本的ADT(版本20预览版3)中,他们说可以使库的清单文件与使用它们的项目合并:

将库项目清单文件自动合并到包含项目的清单中.使用manifestmerger.enabled属性启用.

我如何以及在何处使用它?我无法在任何地方看到内容帮助我.

android adt android-manifest android-library

43
推荐指数
3
解决办法
2万
查看次数

如何正确过滤包替换广播

我试图抓住包替换广播为我的应用程序和我的应用程序,但由于某些原因在我的收件人我是广播的每个更新的应用程序.我以为你只需要将清单文件中的intent过滤器设置到你的应用程序,但也许我错了?

这是我的代码(清单):

        <receiver android:name=".UpdateReciever">
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REPLACED" />
            <data android:scheme="package" android:path="com.my.app" />
        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

Reciever:

public class AppUpdateReciever extends BroadcastReceiver {

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

        //code..    
    }

}
Run Code Online (Sandbox Code Playgroud)

android broadcast intentfilter broadcastreceiver

20
推荐指数
1
解决办法
1万
查看次数

Android:广播ACTION_MY_PACKAGE_REPLACED从未收到过

我的应用程序运行的服务在设备重新启动或重新安装(更新)应用程序时终止.我添加了两个广播接收器来捕获这些事件 - BOOT_COMPLETED和ACTION_MY_PACKAGE_REPLACED.

ACTION_MY_PACKAGE_REPLACED接收器似乎不起作用.这就是我所拥有的:

AndroidManifest.xml中:

    <receiver android:name=".RebootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>
    <receiver android:name=".ReInstallReceiver">
        <intent-filter>
            <action android:name="android.intent.action.ACTION_MY_PACKAGE_REPLACED"/>
        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

RebootReceiver:

public class RebootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Logg.d("Reboot completed. Restarting service");
        context.startService(new Intent(context, MyService.class));
    }
}
Run Code Online (Sandbox Code Playgroud)

ReInstallReceiver:

public class ReInstallReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Logg.d("App Upgraded or Reinstalled. Restarting service");
        context.startService(new Intent(context, MyService.class));
    }
}
Run Code Online (Sandbox Code Playgroud)

运行minSdk = 16; 在运行KitKat的Galaxy S3上进行测试.通过检查我的服务是否在"设置/应用程序"中运行来测试成功,它在重新启动时执行,但不重新安装.

我已经考虑了以下注释,其中说在Android Studio 1.0+中,清单合并意味着我无法将两个接收器合并为一个类.请参阅ACTION_MY_PACKAGE_REPLACED未收到,并且对于具有相同名称但内容不同的接收者,Android清单合并失败

android broadcastreceiver android-broadcast android-studio

6
推荐指数
3
解决办法
7256
查看次数

android.intent.action.MY_PACKAGE_REPLACED 不工作

我似乎无法理解这一点,也看不到它在 Logcat 中发送。通过审查未收到 ACTION_MY_PACKAGE_REPLACED,看来 MY_PACKAGE_REPLACED 应该是我对 API22 所需的全部。

我缺少什么?

谢谢。

AndroidManifest.xml 中的片段

    <receiver
        android:name=".BootReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

引导接收器

class BootReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        if (intent.action == "android.intent.action.BOOT_COMPLETED" ||
                intent.action == "android.intent.action.MY_PACKAGE_REPLACED") {
            Log.d(TAG, "Caught BOOT_COMPLETED or PACKAGE_REPLACED action!")
            GlobalScope.launch(Dispatchers.IO) {
                ...
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

android intentfilter broadcastreceiver android-intent kotlin

6
推荐指数
1
解决办法
3828
查看次数

对于具有相同名称但内容不同的接收者,Android清单合并失败

我有重复接收器的清单合并问题,但内容不同.我使用以下接收器用于不同的API级别,到目前为止没有问题直到合并.由于合并而导致构建失败

Element receiver#.receivers.UpdateReceiver duplicated with element declared at AndroidManifest.xml:124:9
Run Code Online (Sandbox Code Playgroud)

我不想创建另一个接收器并继续使用此架构.是否有任何方法可以禁用那些情况下的合并,或者将接收器合并为一个但是可以选择启用具有不同意图的操作?

<receiver
    android:name=".receivers.UpdateReceiver"
    android:enabled="@bool/is_api_below_12">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_REPLACED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>

<receiver
    android:name=".receivers.UpdateReceiver"
    android:enabled="@bool/is_api_12_and_above">
    <intent-filter>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

android android-manifest

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

广播接收器 MY_PACKAGE_REPLACED 从未调用

我有以下应用程序场景:1) 一个自行更新的应用程序 2) 设备已植根 3) 在线检查版本,如果新版本在线,它会下载“apk”文件并安装它

一切正常,但新版本安装后应用程序不会重新启动。我试图设置 MY_PACKAGE_REPLACED 广播接收器,但它从未被调用。应用程序安装新的并停止,但应用程序中的接收器从未被触发。

我究竟做错了什么?

代码:清单

<receiver android:name=".receivers.OnUpgradeReceiver">
            <intent-filter>
              <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
              <data android:scheme="package"/>
          </intent-filter>
        </receiver>
Run Code Online (Sandbox Code Playgroud)

我尝试了带有 DATA 部分的接收器清单代码而没有......但它仍然不起作用!!

广播接收器类

public class OnUpgradeReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        final String msg="intent:"+intent+" action:"+intent.getAction();
        Log.e("OLE","RECEIVEEEEEEEEEEEEEEEEEEEEEED: "+msg);
    }}
Run Code Online (Sandbox Code Playgroud)

APP更新部分

Process p;  
                    try {  

                        //Runtime.getRuntime().exec (new String[]{"su", "-c", "pm install -r " + apkLocation +  "party.net"});

                            // Preform su to get root privledges  
                            p = Runtime.getRuntime().exec("su");   

                            // Attempt to write a file to a …
Run Code Online (Sandbox Code Playgroud)

android auto-update broadcastreceiver

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