0

While launching the app I have requested permission and the request permission popup shows but after the app crashed alert. when i clicked OK button in the crashed popup it disappears and the app work's good

regards...

here is my code

 protected override void OnCreate(Bundle savedInstanceState)
    { 
        base.OnCreate(savedInstanceState);

        SetContentView(Resource.Layout.Login);
        Requestpermission();
    }

 private void Requestpermission()
    {

        if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadPhoneState) == Permission.Granted)
        {

        }
        else
        {
            ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.ReadPhoneState }, PERMISSION_REQUEST_CODE);
        }
    }

here is my image after app installed..........

enter image description here

after clicking Ok .........

enter image description here

LOG:

Error 5368 AndroidRuntime Caused by: java.lang.SecurityException: getDeviceId: Neither user 10321 nor current process has android.permission.READ_PHONE_STATE. at android.os.Parcel.readException(Parcel.java:1599) at android.os.Parcel.readException(Parcel.java:1552) at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:4426) at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:731) at md57d354519be1a75e7f096fe21d2760d3a.Login_Activity.n_onCreate(Native Method) at md57d354519be1a75e7f096fe21d2760d3a.Login_Activity.onCreate(Login_Activity.java:31) at android.app.Activity.performCreate(Activity.java:6309) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)

Nandha
  • 375
  • 3
  • 23
  • It would be a good idea, to add any stack trace information that you were given, along with relevant snippets of code relating to where the error was being thrown within your solution. Otherwise we have no way to help you. – JoeTomks Mar 20 '18 at 14:58
  • added my code.. – Nandha Mar 20 '18 at 15:03
  • Please add the logs. – Robbit Mar 21 '18 at 02:58
  • i didn't got errors in my log – Nandha Mar 21 '18 at 04:51
  • it says deploy succeeded...after that log is blank – Nandha Mar 21 '18 at 04:55
  • Add [IUncaughtExceptionHandler](https://stackoverflow.com/questions/39668236/how-to-properly-write-a-custom-uncaughtexceptionhandler-in-xamarin-android?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) to capture global exceptions. Or check if you have do something which spend too much time so that it block your UI thread. Or you can use [Diagnostic MSBuild Output](https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/troubleshooting) to get more logs. – Robbit Mar 21 '18 at 08:01
  • updated my post @JoeLv-MSFT – Nandha Mar 21 '18 at 08:50
  • Have you added `READ_PHONE_STATE` permission in your manifest? – Robbit Mar 21 '18 at 09:15
  • If your runtime permission request is right, try to delete bin and obj, restart VS. – Robbit Mar 21 '18 at 09:25
  • already done that...still problem exists – Nandha Mar 21 '18 at 11:50

0 Answers0