简体   繁体   English

单色接收器PACKAGE_REMOVED java.lang.ClassNotFoundException

[英]monodroid receiver PACKAGE_REMOVED java.lang.ClassNotFoundException

I am using monodroid. 我正在使用monodroid。 I keep receiving java.lang.ClassNotFoundException error when the PACKAGE_REMOVED action is trapped. 捕获PACKAGE_REMOVED操作时,我不断收到java.lang.ClassNotFoundException错误。 I have searched and attempted many things on stackflow and other sites, but can not get this working. 我已经在stackflow和其他站点上搜索并尝试了很多方法,但是无法正常工作。 Any help would be appreciated. 任何帮助,将不胜感激。

AndroidManifest.xml AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly">
<uses-sdk android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/Icon" android:label="App Store">
<receiver android:name=".PackageChangeReceiver" android:exported="true" android:enabled="true">
  <intent-filter android:priority="999">
    <action android:name="android.intent.action.PACKAGE_REMOVED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="package" />
  </intent-filter>
</receiver>
</application>
</manifest>

Broadcast Receiver (PackageChangeReceiver.cs) 广播接收器(PackageChangeReceiver.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System.Net;
using System.IO;
using Android.Util;

namespace AppStore
{
[BroadcastReceiver]
public class PackageChangeReceiver : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
        if ("android.intent.action.PACKAGE_REMOVED".Equals(intent.Action))
        {
            Boolean replacing = intent.GetBooleanExtra(Intent.ExtraReplacing, false);
            if (replacing)
            {
                //do nothing because will be reinstalled again
            }
            else
            {
                Intent pushIntent = new Intent(context, typeof(UpdatesService));
                pushIntent.PutExtra("appname", intent.Data.ToString());
                context.StartService(pushIntent);  
            }
        }
    }
}
}

I Contacted Xamarin ( Monodroid ) directly. 我直接联系Xamarin(Monodroid)。 It seems my mistake was in editing the manifest manually. 看来我的错误在于手动编辑清单。 I had done a web search looking for solutions and added entries to the manifest. 我进行了一次网络搜索以寻找解决方案,并在清单中添加了条目。 However, this did not connect with the monodroid code. 但是,这与monodroid代码无关。 Since monodroid autobuilds the manifest, you have to use attributes on the broadcast receiver like so: 由于monodroid自动构建清单,因此您必须像下面这样在广播接收器上使用属性:

[BroadcastReceiver] 
[IntentFilter(new string[] { Intent.ActionPackageRemoved }, Priority = (int)IntentFilterPriority.HighPriority, DataScheme="package")] 
public class PackageChangeReceiver : BroadcastReceiver 
{

Hope this helps others. 希望这对其他人有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.RuntimeException和java.lang.classNotFoundException - java.lang.RuntimeException and java.lang.classNotFoundException Xamarin 使用 CallRedirectionService 抛出 Java.Lang.ClassNotFoundException - Xamarin throws Java.Lang.ClassNotFoundException using CallRedirectionService Java.Lang.ClassNotFoundException:找不到类“ android.view.CoordinatorLayout” - Java.Lang.ClassNotFoundException: Didn't find class “android.view.CoordinatorLayout” AndroidJavaException:java.lang.ClassNotFoundException:找不到类“ com.unity3d.player.ReflectionHelper” - AndroidJavaException: java.lang.ClassNotFoundException: Didn't find class “com.unity3d.player.ReflectionHelper” AndroidRuntime引起原因:java.lang.ClassNotFoundException:找不到类“ android.support.multidex.MultiDexApplication” - AndroidRuntime Caused by: java.lang.ClassNotFoundException: Didn't find class “android.support.multidex.MultiDexApplication” AndroidJavaException:java.lang.ClassNotFoundException:com.google.unity.ads.UnityInterstitialAdCallback - AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityInterstitialAdCallback 如何从MonoDroid中的重写方法返回Java.Lang.Object - How to return Java.Lang.Object from a overridden method in MonoDroid C#Monodroid / Xamarin-定位服务Java.Lang.IllegalArgumentException - C# Monodroid/Xamarin - Location Services Java.Lang.IllegalArgumentException Teechart,Monodroid Java.Lang.IllegalArgumentException:指针索引超出范围 - Teechart, Monodroid Java.Lang.IllegalArgumentException: pointerIndex out of range 用于Java反射的Monodroid JNI调用私有方法 - Monodroid JNI for Java reflection to call a private method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM