Error in Xam.Plugin.Media

AmirImamAmirImam USMember ✭✭
edited February 11 in Xamarin.Forms

Hi
I want to get an image from device camera, so I have used Xam.Plugin.Media .. and I followed the instructions in readme file but I got this error on MainActivity in base.OnCreate(bundle); .. and "bundle" is null

_Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setId(int)' on a null object reference
_
So what is the problem ?

Update:

My current code:

In MainActivity
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
         {
             Plugin.Permissions.PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
         }

and this in OnCreate

`CrossCurrentActivity.Current.Init(this, bundle);`

And for "CrossCurrentActivity" I have created MainApplication class like this:

    public class MainApplication : Application
    {
    public override void OnCreate()
    {
    CrossCurrentActivity.Current.Init(this);
    }
    }

I didn't try the iOS implementation yet

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I think you should post some code

  • AmirImamAmirImam USMember ✭✭
    edited February 11

    @AlessandroCaliaro said:
    I think you should post some code

    There is no code yet .. but I think I have this in MainActivity.cs

         public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
                {
                    Plugin.Permissions.PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
                }
    

    and this in OnCreate

    `CrossCurrentActivity.Current.Init(this, bundle);`
    

    And for "CrossCurrentActivity" I have created MainApplication class like this:

        public class MainApplication : Application
        {
        public override void OnCreate()
        {
        CrossCurrentActivity.Current.Init(this);
        }
        }
    

    I didn't try the iOS implementation yet

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    Could you please post more detailed codes? or maybe share a basic demo that can reproduce the problem through online repo

Sign In or Register to comment.