Setting the password programatically giving Security exception - android

I am trying to set lock password on android using the below code , I have referenced How can i set up screen lock with a password programmatically?
I am getting the following exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smsapp.helpme/com.smsapp.helpme.LockActivity}: java.lang.SecurityException: Admin ComponentInfo{com.smsapp.helpme/com.smsapp.helpme.LockAdminReceiver} did not specify uses-policy for: limit-password
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.SecurityException: Admin ComponentInfo{com.smsapp.helpme/com.smsapp.helpme.LockAdminReceiver} did not specify uses-policy for: limit-password
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.setPasswordQuality(IDevicePolicyManager.java:2029)
at android.app.admin.DevicePolicyManager.setPasswordQuality(DevicePolicyManager.java:754)
at com.smsapp.helpme.LockActivity.onCreate(LockActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) 
at android.app.ActivityThread.access$800(ActivityThread.java:155) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5343) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 
Code which i have added:
device_xml
<uses-policies>
<limit-password />
<watch-login />
<reset-password0 />
<force-lock />
<wipe-data />
<expire-password />
<encrypted-storage />
<disable-camera />
</uses-policies>
mDevicePolicyManager.setPasswordQuality(
mComponentName,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
mDevicePolicyManager.setPasswordMinimumLength(mComponentName, 5);
boolean result = mDevicePolicyManager.resetPassword("123456",
DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);

Related

Trying to run an app using dl4j on Android

I am trying to run a simple app using the deep learning library dl4j.
I am working on Android Studio and using Gradle.
During runtime, I get the following exception:
08-15 13:23:00.601 4868-4868/com.mi.dl E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mi.dl, PID: 4868
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java) 
at android.view.View$PerformClick.run(View.java) 
at android.os.Handler.handleCallback(Handler.java) 
at android.os.Handler.dispatchMessage(Handler.java) 
at android.os.Looper.loop(Looper.java) 
at android.app.ActivityThread.main(ActivityThread.java) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
Caused by: java.lang.ExceptionInInitializerError
at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485)
at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79)
at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70)
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java) 
at android.view.View$PerformClick.run(View.java) 
at android.os.Handler.handleCallback(Handler.java) 
at android.os.Handler.dispatchMessage(Handler.java) 
at android.os.Looper.loop(Looper.java) 
at android.app.ActivityThread.main(ActivityThread.java) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
Caused by: java.lang.RuntimeException: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5151)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:169)
at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485) 
at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79) 
at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java) 
at android.view.View$PerformClick.run(View.java) 
at android.os.Handler.handleCallback(Handler.java) 
at android.os.Handler.dispatchMessage(Handler.java) 
at android.os.Looper.loop(Looper.java) 
at android.app.ActivityThread.main(ActivityThread.java) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
Caused by: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:178)
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5148)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:169) 
at org.deeplearning4j.nn.conf.NeuralNetConfiguration$Builder.seed(NeuralNetConfiguration.java:485) 
at com.mi.dl.MLPClassifierLinear.main(MLPClassifierLinear.java:79) 
at com.mi.dl.MyActivity.sendMessage(MyActivity.java:70) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java) 
at android.view.View$PerformClick.run(View.java) 
at android.os.Handler.handleCallback(Handler.java) 
at android.os.Handler.dispatchMessage(Handler.java) 
at android.os.Looper.loop(Looper.java) 
at android.app.ActivityThread.main(ActivityThread.java) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 
in the build.gradle file, I have the following dependency:
compile 'org.nd4j:nd4j-native-platform:0.5.0'
but I have also tried different backends.
The dl4j team said Android is not supported yet, but I would still like to try to make it work, so any help would be appreciated.

Starting React Native on Android Version 5.0

So I am running into an error on Android Version 5.0. It occurs when I build my react native instance manger like so:
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(application)
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new CodePush(BuildConfig.CODEPUSH_KEY, application, BuildConfig.DEBUG))
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.BEFORE_RESUME)
.setJSBundleFile(CodePush.getJSBundleFile())
.build();
It's odd because I tested a production build on those phones, but they never had this issue before. The bug I am getting is this:
FATAL EXCEPTION: main
Process: something.something, PID: 10140
java.lang.RuntimeException: Unable to start activity ComponentInfo{something.something/something.something.activity.SomeKindOfActivity}: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:79)
at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:326)
at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:227)
at something.something.activity.SomeKindOfActivity.createReactInstanceManager(SomeKindOfActivity.java:356)
at something.something.activity.SomeKindOfActivity.onCreate(SomeKindOfActivity.java:205)
at android.app.Activity.performCreate(Activity.java:6283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5942) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:72)
at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:326) 
at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:227) 
at something.something.activity.SomeKindOfActivity.createReactInstanceManager(SomeKindOfActivity.java:356) 
at something.something.activity.SomeKindOfActivity.onCreate(SomeKindOfActivity.java:205) 
at android.app.Activity.performCreate(Activity.java:6283) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5942) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient$Builder;
at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:107)
at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:190)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:72) 
at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:326) 
at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:227) 
at something.something.activity.SomeKindOfActivity.createReactInstanceManager(SomeKindOfActivity.java:356) 
at something.something.activity.SomeKindOfActivity.onCreate(SomeKindOfActivity.java:205) 
at android.app.Activity.performCreate(Activity.java:6283) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5942) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.OkHttpClient$Builder" on path: DexPathList[[zip file "/data/app/something.something-2/base.apk", zip file "/data/app/something.something-2/split_lib_dependencies_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_0_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_1_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_2_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_3_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_4_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_5_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_6_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_7_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_8_apk.apk", zip file "/data/app/something.something-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/something.something-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:107) 
at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:190) 
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:72) 
at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:326) 
at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:227) 
at something.something.activity.SomeKindOfActivity.createReactInstanceManager(SomeKindOfActivity.java:356) 
at something.something.activity.SomeKindOfActivity.onCreate(SomeKindOfActivity.java:205) 
at android.app.Activity.performCreate(Activity.java:6283) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5942) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
Suppressed: java.lang.ClassNotFoundException: okhttp3.OkHttpClient$Builder
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.j

why “addView not supported in adapterview” error give on add ads dependency in gradle compile 'com.google.android.gms:play-services-ads:10.2.0'

when i add Ads dependency its give error
FATAL EXCEPTION: main
Process: com.unnamed.b.atv.demo, PID: 1342
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unnamed.b.atv.demo/com.unnamed.b.atv.sample.activity.SingleFragmentActivity}: java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2656)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
at android.app.ActivityThread.access$900(ActivityThread.java:168)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5753)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView
at android.widget.AdapterView.addView(AdapterView.java:469)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1120)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:619)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1232)
at android.app.Activity.performStart(Activity.java:6147)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721) 
at android.app.ActivityThread.access$900(ActivityThread.java:168) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5753) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200) 

android- XML OnClick Method not working

I'm getting the following error:
04-16 14:29:02.281 4845-4845/com.example.rswat.mychatapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.rswat.mychatapp, PID: 4845
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5637) 
at android.view.View$PerformClick.run(View.java:22429) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6119) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
Caused by: java.lang.IllegalArgumentException: Invalid to:
at com.google.firebase.messaging.RemoteMessage$Builder.<init>(Unknown Source)
at com.example.rswat.mychatapp.MainActivity.onClick(MainActivity.java:33)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java:5637) 
at android.view.View$PerformClick.run(View.java:22429) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6119) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
Please help...! Thanks a lot...!
XML Layout
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:onClick="buttonClick"
android:text="#string/button" />
Activity Class
public void buttonClick(View view){
}
Your issue is with the Firebase code, not the XML onClick-property. Try moving your Firebase code to the onCreate-method, and you'll see that the app crashes as well. Feel free to post the new Logcat log here.

How to Check for “enabled_notification_listeners” Programmatically?

I need to check that either my application's service is Enabled or Not in "Notification Access".
I am using this code to check this. The code is running fine on Nougat, but it crashes on Marshmallow. How can I do that on Marshmallow?
android.provider.Settings.Secure.getString(this.getContentResolver(), "enabled_notification_listeners").contains(getApplicationContext().getPackageName())
This is the Error in LogCat:
12-06 15:28:02.905 4428-4428/com.inetsoho.app.SkyChat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.inetsoho.app.SkyChat, PID: 4428
java.lang.IllegalStateException: Could not execute method for
android:onClick
at android.view.View$DeclaredOnClickListener.onClick(View.java:4740)
at android.view.View.performClick(View.java:5697)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4735)
at android.view.View.performClick(View.java:5697) 
at android.view.View$PerformClick.run(View.java:22526) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual
method 'boolean java.lang.String.contains(java.lang.CharSequence)' on
a null object reference
at
com.inetsoho.app.SkyChat.ui.activities.authorization.LandingActivity.SignUpPhoneNumberOnClickListener(LandingActivity.java:110)
at java.lang.reflect.Method.invoke(Native Method) 
at android.view.View$DeclaredOnClickListener.onClick(View.java:4735) 
at android.view.View.performClick(View.java:5697) 
at android.view.View$PerformClick.run(View.java:22526) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Resources