Android Home Button Disable error - java

I'm developing some android application .In application i want to disable home button .
So i tried to overide onAttachedToWindow method, but the problem is i getting a error when start application.
Code :
#Override
public void onAttachedToWindow(){
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
Error :
java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
at android.os.Parcel.readException(Parcel.java:1603)
at android.os.Parcel.readException(Parcel.java:1552)
at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:912)
at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:5415)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1581)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
any one have idea , what is the error of this code ?

I found the answer for my question . in android Lolipop have startLockTask() funciton.this will pin your task. thak you all .

As I mentioned in other question, you are not able to disable or override, or even detect home button.
Set type of window you can only before setContentView().

Related

Java android event bus open camera

On android 7.0 when I want to open a camera in logs I see this :
EventBus: Could not dispatch event: class pl.eltegps.smokkomunikator.event.PhotoRequestedEvent to subscribing class class pl.eltegps.smokkomunikator.ui.activity.MainActivity
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/pl.eltegps.smokkomunikator/images/gps_TEMP.jpg exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
at android.net.Uri.checkFileUriExposed(Uri.java:2346)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9483)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9468)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.Activity.startActivityForResult(Activity.java:4399)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:4358)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:871)
at pl.eltegps.smokkomunikator.ui.activity.MainActivity.onPhotoRequestedEvent(MainActivity.java:399)
at java.lang.reflect.Method.invoke(Native Method)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485)
at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:416)
at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:397)
at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:370)
at org.greenrobot.eventbus.EventBus.post(EventBus.java:251)
at pl.eltegps.smokkomunikator.ui.fragment.NewMessageFragment.photo(NewMessageFragment.java:259)
at pl.eltegps.smokkomunikator.ui.fragment.NewMessageFragment$$ViewBinder$1.doClick(NewMessageFragment$$ViewBinder.java:28)
at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
at android.view.View.performClick(View.java:6199)
at android.view.View$PerformClick.run(View.java:23647)
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:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
On android 4.4.2 I check and it works corretly, but on new android it doesn't works corretly and I don't know why ...
This is a problem I faced also faced while testing on 7.0 . Seems like you can not use getUri() Directly on 7.0 without the use of content provider.
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
FileProvider.getUriForFile(getActivity(), getActivity().getApplicationContext().getPackageName() + ".provider", f));
You will have to use this and add a provider.xml in xml directory of your project.
this link has detailed explaination about it.

Android ProgessDialog weird console error message

I have a simple ProgessDialog. I show the dialog, call a method and later inside the method I hide the dialog but I am getting a console error.
ProgressDialog progressDialog = new ProgressDialog(ChangeEmailActivity.this);
progressDialog.setTitle("Loading");
progressDialog.show();
Inside the method
progressDialog.hide();
E/WindowManager: android.view.WindowLeaked: Activity de.at_c.liftkey.ChangeEmailActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{10f2f3a8 G.E..... R.....ID 0,0-729,322} that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:363)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:271)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.app.Dialog.show(Dialog.java:298)
at de.at_c.liftkey.ChangeEmailActivity$1.onClick(ChangeEmailActivity.java:42)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Use
progressDialog.dismiss();
Instead of
progressDialog.hide();
You need to dismiss the dialog instead of hiding it.
Try running progressBar.dismiss() before the activity or fragment holding it is destroyed. Can always put it in the onDestroy() method.

android - Short sounds on MediaPlayer throw NullPointerException

I have encountered a problem in which when ever I use
final MediaPlayer tick = MediaPlayer.create(getApplicationContext(), R.raw.tick);
tick.start();// tick is a short .mp3 file
in my app, no matter where, I get:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference
at com.a.aar.MainActivity.onClicks(MainActivity.java:123)
at com.a.aar.MainActivity$2.onClick(MainActivity.java:97)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
But, whenever I use a slightly shorter sound effect, the app runs great.(I need a short sound because I want a lot of sounds coming fast and so the sounds will not stop)
What is the reason to this error and how can I solve it?

Android testfairy java.lang.VerifyError?

After I upload my apk to testfairy and install it I get a java.lang.VerifyError crash
The class extends android.support.v4.app.Fragment
This is the function that is crashing. It crashes on the function execution, not the click but when I remove the onClick. Inner stuff all works.
fitroom_lly is LinearLayout
mixpanel defined :
MixpanelAPI mixpanel = MixpanelAPI.getInstance(getActivity(), getResources().getString(R.string.Mix_Panel_Token));
Function:
private void AddOnFittingRoomClickListener() {
fitroom_lly.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
mixpanel.track("Fitting room");
}
});
}
Error:
java.lang.VerifyError: co/slider/fashion/Slider/SliderFragment$6
at co.slider.fashion.Slider.SliderFragment.AddOnFittingRoomClickListener(SliderFragment.java:334)
at co.slider.fashion.Slider.SliderFragment.onCreateView(SliderFragment.java:135)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
I work for TestFairy. I need a bit information, is your app multidex'd or a single dex? That's the only VerifyError we ever encountered, and we have an answer for that. Though I would need you to email support at testfairy.com, and one of the technical developer will explain to you the workaround. We're making this solution available to everybody, but in the meanwhile, only support is explaining this.

Quickblox: Android Video Calling Shows java.lang.NoSuchMethodError: No static method registerComplexPropertyParser

Used native-libs.jar. Following the same method as given in the sample. Currently using quickblox-android-sdk-videochat-webrtc-2.4. Trying using the sample code QBRTCClient shows the below error message:
java.lang.NoSuchMethodError: No static method registerComplexPropertyParser(Ljava/lang/String;Lcom/quickblox/chat/propertyparsers/MessagePropertyParser;)V in class Lcom/quickblox/chat/model/QBChatMessageExtension; or its super classes (declaration of 'com.quickblox.chat.model.QBChatMessageExtension' appears in /data/app/xxx.xxx.xxx/base.apk)
at com.quickblox.videochat.webrtc.RTCSignallingMessageProcessor.<clinit>(RTCSignallingMessageProcessor.java:38)
at com.quickblox.videochat.webrtc.QBRTCClient.<init>(QBRTCClient.java:93)
at com.quickblox.videochat.webrtc.QBRTCClient.getInstance(QBRTCClient.java:124)
at xxx.xxx.xxx.Activity.CallActivity.initQBRTCClient(CallActivity.java:125)
at xxx.xxx.xxx..Activity.CallActivity.onCreate(CallActivity.java:119)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2312)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2421)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5329)
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:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
I was using multiple version of library for chat, video and core, so i contacted Quickblox and they told me to use the same version of library for all. Hope this helps.
Thank You

Categories