IllegalArgumentException from closing service that draws on other apps - android

I am writing an android app that runs a service in the background that makes use of the OVERLAY_PERMISSION to draw on other apps. It starts with an intent from a button on my main activity. So far, so good.
In my service, in my onDestroy(), I have a if (myView != null) windowManager.removeView(myView);. And when I call stopService from the activity, I get an error, saying:
java.lang.RuntimeException: Unable to stop service com.supernovaapps.cameralevel.LevelService#ed1633f: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
I am only able to close the service if I comment out that line. However, if I do that, the view remains on the screen even after the service is closed, which is not what I want.
What is the correct way to close the service and detach the view?
Full Trace:
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: FATAL EXCEPTION: main
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: Process: com.supernovaapps.cameralevel, PID: 21233
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: java.lang.RuntimeException: Unable to stop service com.supernovaapps.cameralevel.LevelService#ed1633f: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.handleStopService(ActivityThread.java:3059)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.-wrap21(ActivityThread.java)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1447)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: Caused by: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:424)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:350)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:111)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.supernovaapps.cameralevel.LevelService.onDestroy(LevelService.java:164)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.handleStopService(ActivityThread.java:3040)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.-wrap21(ActivityThread.java) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1447) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)

Looks like you passed a different view to windowManager than what was added to it before.
Just pass it the right view and it would work.

Related

Get error when back to the previous activity in intent

In My app When I go to the settings activity then back, my app force to stop the activity, I don't know which mistake is there.Please help me to solve that. Thanks for your help in advance!
08-13 11:36:36.355 21968-21968/com.example.user.dictationapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.dictationapp, PID: 21968
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.dictationapp/com.example.user.dictationapp.DictationVocab}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.widget.CompoundButton.onRestoreInstanceState(CompoundButton.java:378)
at android.view.View.dispatchRestoreInstanceState(View.java:12842)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2658)
at android.view.View.restoreHierarchyState(View.java:12820)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1874)
at android.app.Activity.onRestoreInstanceState(Activity.java:949)
at android.app.Activity.performRestoreInstanceState(Activity.java:921)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
Having experienced these ClassCastExceptions before, I'd suggest that you check that you do not have a same id being shared by different widgets. Also, check with layouts in different layout-qualifiers folders for the same condition.

Java.lang.IllegalStateException Activity has been destroyed

I know there are lots of same question and I checked its solutions\ suggestions. However, they are not working for me. I am trying to add fragment and when I am calling fragmentTransaction.commit() it throws that exception, but that happens only with my 2nd fragment.
I send a notification to my application, when it is clicked, it opens my app which open main fragment, at that time getSupportFragmentManager().findFragmentById(R.id.rl_content_fragment); returns null for current fragment ( which should be correct ), problem is my 2nd fragment ( playerFragment) when I try to add it ( while debugging) I found out that getSupportFragmentManager() still returns null for current fragment and it throws the exception that the activity has been destroyed when I call fragmentTransaction.commit().
My questions
1-is why does the Activity gets destroyed or finish while the application is starting?
2-how can I fix that issue?
Any hint will be appreciated, thanks.
EDIT this is the exception which I get, I know I should not change views unless I am on mainThread, but I do report on main thread, Sorry forgot to say we are using commitAllowingStateLoss() and this what i get
java.lang.IllegalStateException: Activity has been destroyed
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1399)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:637)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:620)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity.addContentFragment(BaseActivity.java:502)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity$3.onCompleted(BaseActivity.java:837)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.EpisodeManager$5.onCompleted(EpisodeManager.java:1107)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:645)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:546)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:632)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:177)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5146)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
and if i use commit() I get this exception
Process: com.myApp, PID: 10659
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1377)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1395)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:637)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:616)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity.addContentFragment(BaseActivity.java:502)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity$3.onCompleted(BaseActivity.java:837)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.EpisodeManager$5.onCompleted(EpisodeManager.java:1107)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:645)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:546)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:632)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:177)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5146)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
sorry for much logs

Crash issue in OnResume

If application stay in background mode more then 5 min. after that i try to open Application at that time got crash issue my Error log is here help me thanks in Advance....
java.lang.RuntimeException: Unable to start activity` ComponentInfo{com.gamestruct.TweetBoostAndroid/com.gamestruct.TweetBoostAndroid.TabbedActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gamestruct.TweetBoostAndroid/com.gamestruct.TweetBoostAndroid.EarnCoinActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.access$800(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5118)
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:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gamestruct.TweetBoostAndroid/com.gamestruct.TweetBoostAndroid.EarnCoinActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2043)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
at android.widget.TabHost.setCurrentTab(TabHost.java:413)
at android.widget.TabHost.addTab(TabHost.java:240)
at com.gamestruct.TweetBoostAndroid.TabbedActivity.addTab(TabbedActivity.java:199)
at com.gamestruct.TweetBoostAndroid.TabbedActivity.setTabs(TabbedActivity.java:180)
at com.gamestruct.TweetBoostAndroid.TabbedActivity.onCreate(TabbedActivity.java:140)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
... 11 more
Caused by: java.lang.NullPointerException
at com.gamestruct.TweetBoostAndroid.EarnCoinActivity.onCreate(EarnCoinActivity.java:110)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
... 23 more
While your application stayed in the background it got killed by the system. Somewhere in com.gamestruct.TweetBoostAndroid.EarnCoinActivity.onCreate (presumably on line 110) you are using something that became null as your app was killed.

Remove item in arrayList , java.lang.UnsupportedOperationException

I want remove item in array list select location
My code is
List<String> historylist = Arrays.asList(history);
if (historylist.size()>=3){
System.out.print("*************************************************");
Log.i(MyContants.StoredHistory_TAG,"StoredHistory size========="+ String.valueOf(historylist.size()));
String removePosition=historylist.get(2);
historylist.remove(removePosition);
}
but i got a Exception UnsupportedOperationException
error
12-20 09:16:27.680: I/StoredHistory Class(5715): StoredHistory size=========3
12-20 09:16:27.680: D/AndroidRuntime(5715): Shutting down VM
12-20 09:16:27.684: W/dalvikvm(5715): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
12-20 09:16:27.688: E/AndroidRuntime(5715): FATAL EXCEPTION: main
12-20 09:16:27.688: E/AndroidRuntime(5715): java.lang.RuntimeException: Unable to start activity ComponentInfo{****PACKAGE NAME*****}: java.lang.UnsupportedOperationException
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.os.Looper.loop(Looper.java:123)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.lang.reflect.Method.invoke(Method.java:521)
12-20 09:16:27.688: E/AndroidRuntime(5715): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-20 09:16:27.688: E/AndroidRuntime(5715): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-20 09:16:27.688: E/AndroidRuntime(5715): at dalvik.system.NativeStart.main(Native Method)
12-20 09:16:27.688: E/AndroidRuntime(5715): Caused by: java.lang.UnsupportedOperationException
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.util.AbstractList.remove(AbstractList.java:645)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:77)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.util.AbstractCollection.remove(AbstractCollection.java:230)
12-20 09:16:27.688: E/AndroidRuntime(5715): at ******.utills.StoredHistory.storedHistorylist(StoredHistory.java:24)
12-20 09:16:27.688: E/AndroidRuntime(5715): at *******.ScanResult.onCreate(ScanResult.java:53)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-20 09:16:27.688: E/AndroidRuntime(5715): ... 11 more
How to cleat this issue .. Advance thanx dude
Change
List<String> historylist = Arrays.asList(history);
to
List<String> historylist = new LinkedList (Arrays.asList(history));
and see this post why this error occur in case of List :
Why do I get an UnsupportedOperationException when trying to remove an element from a List?
You cannot add or remove elements from the list returned by Arrays.asList because the list is backed by the original array. To create a list that you can modify, you can do this:
List<String> historylist = new ArrayList<String>(Arrays.asList(history));
I believe Arrays.asList() creates is fixed-length, and so does not support removing.
Try using an implementation that supports removing like ArrayList instead.
try this
list.set(position,obj);

AdMob on Galaxy Nexus - Android App closed itself

I have programmed a simple app for testing some things.
One thing is AdMob.
On most of the Android Phone it works, but on Galaxy S3 or Galaxy Nexus, or on Tablets not. Maybe there is a Problem with the higher resoltuion?
The problem is that the app closes immediately when it starts. I tried to integrate AdMob on XML, but that does not work with the new version really.
Here is my AdMob Code.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
AdView adView = new AdView(this, AdSize.BANNER, "replaced id with this");
//adView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
LinearLayout layout = (LinearLayout)findViewById(R.id.LayoutMain);
layout.addView(adView,0);
adView.loadAd(adRequest);
And here is the LogCat
12-20 18:39:18.056: I/dalvikvm(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-20 18:39:18.066: I/dalvikvm(541): at dalvik.system.NativeStart.main(Native Method)
12-20 18:39:18.086: D/AndroidRuntime(541): Shutting down VM
12-20 18:39:18.096: W/dalvikvm(541): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-20 18:39:18.206: E/AndroidRuntime(541): FATAL EXCEPTION: main
12-20 18:39:18.206: E/AndroidRuntime(541): java.lang.RuntimeException: Unable to start activity ComponentInfo{at.android.dertestloerk/at.android.dertestloerk.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.os.Looper.loop(Looper.java:137)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-20 18:39:18.206: E/AndroidRuntime(541): at dalvik.system.NativeStart.main(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.Activity.setContentView(Activity.java:1835)
12-20 18:39:18.206: E/AndroidRuntime(541): at at.android.dertestloerk.MainActivity.onCreate(MainActivity.java:27)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.Activity.performCreate(Activity.java:4465)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-20 18:39:18.206: E/AndroidRuntime(541): ... 11 more
12-20 18:39:18.206: E/AndroidRuntime(541): Caused by: java.lang.reflect.InvocationTargetException
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Constructor.constructNative(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
12-20 18:39:18.206: E/AndroidRuntime(541): ... 23 more
12-20 18:39:18.206: E/AndroidRuntime(541): Caused by: java.lang.OutOfMemoryError
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.nativeCreate(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.content.res.Resources.loadDrawable(Resources.java:1937)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.View.<init>(View.java:2780)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.View.<init>(View.java:2717)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.ViewGroup.<init>(ViewGroup.java:379)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.widget.RelativeLayout.<init>(RelativeLayout.java:174)
12-20 18:39:18.206: E/AndroidRuntime(541): ... 26 more
12-20 18:39:23.096: I/Process(541): Sending signal. PID: 541 SIG: 9
And here is my XML Layout
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LayoutMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/hintergrund"
android:orientation="vertical"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/imageViewLoerg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:src="#drawable/animatedloerg"
tools:ignore="ContentDescription" /> </LinearLayout>
Hope you can help .-)
This has nothing to do with Admob. The error is at:
18:39:18.206: E/AndroidRuntime(541): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 12-20 18:39:18.206: E/AndroidRuntime(541): at
Ie it is crashing trying to load the XML layout, long before you programmatically ad in the Admob AdView.
Look at your layout, there is a problem there.

Categories

Resources