0
votes

Okay so i have a weird error here that i can't figure out. I am sharing data with share option list in android "android.intent.action.SEND".

Sharing single image works perfectly, but when i try to share just plain text such as "asdfdgdsfsa", the program throws this error

"Java.Lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.companyname.Revamp/Revamp.RecieveDataFromApp.RecieveDataFromApp}: java.lang.ClassNotFoundException: Didn't find class "Revamp.RecieveDataFromApp.RecieveDataFromApp" on path: DexPathList[[zip file "/data/app/com.companyname.Revamp-HFm6SmD1Y-A76OQwcwCXIA==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.Revamp-HFm6SmD1Y-A76OQwcwCXIA==/lib/x86, /system/fake-libs, /data/app/com.companyname.Revamp-HFm6SmD1Y-A76OQwcwCXIA==/base.apk!/lib/x86, /system/lib, /vendor/lib]] ".

  protected override void OnCreate(Bundle bundle)
    {

        Intent intent = Intent;
        String action = Intent.Action;
        String type = intent.Type;

        if (Intent.ActionSend.Equals(action) && type != null)
        {
            // This is what we are trying to get working here. 
            if ("text/plain".Equals(type))
            {
                // Handle text being sent
                // ...
                // ...
                // ...     
            }
            else if (type.StartsWith("image/"))
            {
                // Handle single image being sent
                // ...
                // ...
                // ...    
            }
        }
        else if (Intent.ActionSendMultiple.Equals(action) && type != null)
        {
            //This works 
            if (type.StartsWith("image/"))
            {
                // Handle multiple images being sent
                // ...
                // ...
                // ...                        
            }
        }
        else
        {
            // Handle other intents, such as being started from the home screen                    
        }

        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);

        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new App());
    }

    <activity android:name="Revamp.RecieveDataFromApp.RecieveDataFromApp" android:icon="@drawable/ic_home">
  <intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
  </intent-filter>
  <intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
  </intent-filter>
  <intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
  </intent-filter>

  <intent-filter>
    <action android:name="android.intent.action.GET_CONTENT" />

    <category android:name="android.intent.category.DEFAULT" />

    <data android:mimeType="*/*" />
  </intent-filter>
</activity>
1
Yeah, I highly doubt the error message you go it "Unable to insatniate activity .. , Didn't find class .. ". How about providing the real error message and the type of the error?rory.ap
Updated to full errorRodnik

1 Answers

1
votes

I have tested your code and reproduce the issue. You could try to set the intent-filter in code, not in AndroidManifest.xml.
For example:

[Activity(Label = "RecieveDataFromApp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "image/*", Label = "RecieveDataFromApp")]
[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "text/plain", Label = "RecieveDataFromApp")]
[IntentFilter(new[] { Intent.ActionSendMultiple }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "image/*", Label = "RecieveDataFromApp")]    
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
   ...
   ...
   ...
}