-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? #2
Comments
here |
but when i deny any permission, app crashes with security exception. did i missed anything.? |
can you post the stacktrace? |
btw, did you add the requested permissions in manifest file? |
|
My manifest `
` |
you need to add these requested permission into your AndroidManifest.xml file check here for examle |
no its not the problem. i think the problem is whenever i press deny permission button, it redirects to method |
I know why @Override
public void granted(List<String> permissions) {
if(permissions.contains(Manifest.permission.GET_ACCOUNTS)){
// get account granted and put your logic here
}
if(permissions.contains(Manifest.permission.READ_CONTACTS)){
// CONTACTS granted and put your logic here
}
} |
It worked . nice. |
My logcat shows
Process: com.root5solutions.myapplication, PID: 12204 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.root5solutions.myapplication/com.root5solutions.myapplication.MainActivity}: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ContextImpl.startActivity(ContextImpl.java:672) at android.app.ContextImpl.startActivity(ContextImpl.java:659) at android.content.ContextWrapper.startActivity(ContextWrapper.java:331) at com.vistrav.ask.Ask.go(Ask.java:56) at com.root5solutions.myapplication.MainActivity.onCreate(MainActivity.java:104) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
i tried to access permissions such as
READ_CONTACT
andGET_ACCOUNTS
by using the code belowThe text was updated successfully, but these errors were encountered: