I had created a class with some stuff I commonly use, like toasts or dialogs. I named this class MyUtils. I had the following lines of code inside MyUtils. Where subYesNoDialogResult is a private variable of type boolean.
public void subYesNoDialog(Context appctx,String title,String mymessage) {
AlertDialog.Builder builder = new AlertDialog.Builder(appctx);
builder.setMessage(mymessage)
.setTitle(title)
.setCancelable(false)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id) {
subYesNoDialogResult = true;
}
})
.setNegativeButton(android.R.string.no,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
subYesNoDialogResult = false;
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
I had another class which is used help the main activity class for certain purpose. I call this class MyDbHelper. I tried to call the above function to show up a Yes/No dialog. This is specifically to get the user's input to make a decision before doing some process inside MyDbHelper class. But I get NullPointerException on doing this. Here is my logcat out put.
I/ActivityManager( 67): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.xxx.geolog/.GeologActivity }
D/AndroidRuntime( 676): Shutting down VM
D/dalvikvm( 676): Debugger has detached; object registry had 1 entries
I/ActivityManager( 67): Start proc com.xxx.geolog for activity com.xxx.geolog/.GeologActivity: pid=683 uid=10040 gids={}
I/AndroidRuntime( 676): NOTE: attach of thread 'Binder Thread #3' failed
D/dalvikvm( 33): GC_EXPLICIT freed 244 objects / 9464 bytes in 704ms
D/dalvikvm( 33): GC_EXPLICIT freed 2 objects / 64 bytes in 350ms
D/dalvikvm( 33): GC_EXPLICIT freed 2 objects / 48 bytes in 536ms
W/GpsLocationProvider( 67): Duplicate add listener for uid 10040
W/WindowManager( 67): Attempted to add window with non-application token WindowToken{44f7d2a0 token=null}. Aborting.
D/AndroidRuntime( 683): Shutting down VM
W/dalvikvm( 683): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 683): FATAL EXCEPTION: main
E/AndroidRuntime( 683): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
E/AndroidRuntime( 683): at android.view.ViewRoot.setView(ViewRoot.java:509)
E/AndroidRuntime( 683): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime( 683): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime( 683): at android.app.Dialog.show(Dialog.java:241)
E/AndroidRuntime( 683): at com.xxx.geolog.SubLocationListener.onProviderDisabled(SubLocationListener.java:33)
E/AndroidRuntime( 683): at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:204)
E/AndroidRuntime( 683): at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:124)
E/AndroidRuntime( 683): at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:140)
E/AndroidRuntime( 683): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 683): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 683): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 683): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 683): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 683): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 683): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 67): Force finishing activity com.xxx.geolog/.GeologActivity
W/ActivityManager( 67): Activity pause timeout for HistoryRecord{45030820 com.xxx.geolog/.GeologActivity}
How can I fix this? Did I do something wrong?
Are you trying to use the application context to show a dialog?
If so try to use an activity context instead to see if it makes a difference.
Actually there is another point. I get the app context, as mibollma said, which is actually an activity context which is the one and only activity in this application which provides the GUI. I get it, and apply type cast to Activity and explicitly set an owner activity. The point here is that, every dialog requires an owner. If they are used inside an Activity class, then the parent activity will become the implicit owner. And if they are used outside an Activity class, you need
dialog_instance.setOwnerActivity(Activity owner);
So in my case, this one line just above alert.show() fixed the issue!
alert.setOwnerActivity((Activity)appctx);
Thanks for your support
Seems like you are not passing the argument Context appctxto the method.
Related
I've created the sample app given in the latest version (current master) of Apache Cordova Facebook Plugin several times:
https://github.com/phonegap/phonegap-facebook-plugin
Currently, I'm working on Android only.
The first time I created this sample app (about two weeks ago) everything worked fine. I successfully logged in with my facebook account, posted a status to my wall and logged out (all the other actions worked fine as well).
But since than I've created this sample app several more times (in the exact same way), and it has never worked again (the last time I tried was today). In the new apps (with the very same code as the first app, which still works), I press "LOGIN WITH FACEBOOK", and my app crashes immediately. Sometimes the app doesn't crash immediately, and I can get the message "Argument 'session' cannot be null". Then I press "LOGIN WITH FACEBOOK" again, and the app crashes. Sometimes I can get this message several times before the app eventually crashes.
If I press "LOGOUT WITH FACEBOOK", I get the message: "No valid session found, must call init and login before logout".
I also don't think that the problem is that I have a wrong hash key or something like that, because I've been careful with the settings of the facebook app every time.
I also believe that I've installed the plugin correctly each time, because I've always done it the same way I did it the first time, which worked fine.
So how is it that in my latest attempts the session variable is NULL??
Why did it work only in the first time??
I'm very frustrated..
Edit:
Here is the relevant segment of the LogCat log:
D/ConnectPlugin( 7064): login FB
W/dalvikvm( 7064): VFY: unable to resolve static field 2130 (com_facebook_internet_permission_error_title) in Lcom/facebook/android/R$string;
D/dalvikvm( 7064): VFY: replacing opcode 0x60 at 0x0010
I/dalvikvm( 7064): DexOpt: unable to optimize static field ref 0x0851 at 0x18 in Lcom/facebook/AuthorizationClient;.checkInternetPermission
W/dalvikvm( 7064): VFY: unable to resolve static field 2120 (com_facebook_login_activity_layout) in Lcom/facebook/android/R$layout;
D/dalvikvm( 7064): VFY: replacing opcode 0x60 at 0x0003
W/dalvikvm( 7064): VFY: unable to resolve static field 2103 (com_facebook_login_activity_progress_bar) in Lcom/facebook/android/R$id;
D/dalvikvm( 7064): VFY: replacing opcode 0x60 at 0x0008
I/ActivityManager( 2112): START {intent.toShortString} from pid 7064
I/power ( 2112): *** acquire_dvfs_lock : lockType : 1 freq : 1000000
D/PowerManagerService( 2112): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1000000 uid : 1000 pid : 2112 tag : ActivityManager
W/ActivityManager( 2112): mDVFSLock.acquire()
D/dalvikvm( 7064): GC_CONCURRENT freed 455K, 6% free 12931K/13639K, paused 4ms+5ms
W/PluginManager( 7064): THREAD WARNING: exec() call to FacebookConnectPlugin.login blocked the main thread for 207ms. Plugin should use CordovaInterface.getThreadPool().
D/CordovaActivity( 7064): Paused the application!
D/CordovaWebView( 7064): Handle the pause
D/FirewallPolicy( 2112): getURLFilterEnabled(true)
D/FirewallPolicy( 2112): isUrlBlocked - Policy disabled
D/webkit ( 7064): Firewall not null
D/FirewallPolicy( 2112): getURLFilterEnabled(true)
D/FirewallPolicy( 2112): isUrlBlocked - Policy disabled
I/ClipboardServiceEx( 2112): mCBPickerDialog enter case. MSG_DISMISS_DIALOG
D/webkit ( 7064): euler: isUrlBlocked = false
D/FirewallPolicy( 2112): getURLFilterEnabled(true)
D/FirewallPolicy( 2112): isUrlBlocked - Policy disabled
D/ActivityManager( 2112): Trying to launch applicationName
D/KeyguardViewMediator( 2112): setHidden false
I/ClipboardServiceEx( 2112): mCBPickerDialog enter case. MSG_DISMISS_DIALOG
D/AndroidRuntime( 7064): Shutting down VM
W/dalvikvm( 7064): threadid=1: thread exiting with uncaught exception (group=0x40c6c1f8)
E/AndroidRuntime( 7064): FATAL EXCEPTION: main
E/AndroidRuntime( 7064): java.lang.NoClassDefFoundError: com.facebook.android.R$layout
E/AndroidRuntime( 7064): at com.facebook.LoginActivity.onCreate(LoginActivity.java:57)
E/AndroidRuntime( 7064): at android.app.Activity.performCreate(Activity.java:4562)
E/AndroidRuntime( 7064): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
E/AndroidRuntime( 7064): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
E/AndroidRuntime( 7064): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
E/AndroidRuntime( 7064): at android.app.ActivityThread.access$600(ActivityThread.java:128)
E/AndroidRuntime( 7064): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
E/AndroidRuntime( 7064): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7064): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 7064): at android.app.ActivityThread.main(ActivityThread.java:4514)
E/AndroidRuntime( 7064): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7064): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 7064): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
E/AndroidRuntime( 7064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
E/AndroidRuntime( 7064): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 2112): Force finishing activity com.yomama.test/com.facebook.LoginActivity
W/ActivityManager( 2112): Force finishing activity com.yomama.test/.Test
Another strange thing that happened to me yesterday was that I recompiled and re-installed (on my phone) the first working app, and suddenly it didn't work either (I got the same message after pressing "LOGIN WITH FACEBOOK", and then the app crashed). Then I recompiled and re-installed the app again, and it was working fine again. Weird.
Try the following steps (from this GitHub issue; had worked for me):
+### Android Setup without Eclipse (just CLI)
+Follow the steps above:
cordova create myApp
cd myApp/
cordova platform add android
cordova -d plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="123456789" --variable APP_NAME="myApplication"
// add FacebookLib
echo "android.library.reference.2=com.phonegap.plugins.facebookconnect/FacebookLib" >> platforms/android/project.properties
cp platforms/android/local.properties platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib
android update project -p platforms/android/
cd platforms/android/
ant clean
cd com.phonegap.plugins.facebookconnect/FacebookLib
ant clean
open -e AndroidManifest.xml
// change your minSdkVersion and your targetSdkVersion to your environment settings.
ant release
cd ../../../..
cordova build android
With this steps you can add the Plugin without using Eclipse
I've got some basic trigger.io code to open a modal dialog for oauth2 authentication:
var url_auth = "http://10.0.0.70/oauth2/authorize";
var oauth_client_id = "123";
var oauth_redirect_uri = "http://done.com/oauth2/complete";
forge.tabs.openWithOptions({
url: url_auth + "?response_type=token&client_id="+ oauth_client_id + "&redirect_url=" + oauth_redirect_uri,
pattern: oauth_redirect_uri + "*",
title: "Authorizing"
}, function(data) { ... });
When the user isn't authenticated, the server redirects to http://10.0.0.70/users to present a login form.
Running the code in an iOS6 simulator yields the correct result:
open modal dialog
server redirects to login form, presented within the dialog
user can authenticate
server redirects to oauth_redirect_uri which trigger catches and closes the dialog
When I run in an android simulator, the initial page is loaded, but then the app crashes.
I see the /oauth2/authorize url being processed on the server
all I see in the debug dialog is "subView load http://10.0.0.70:3000/users"
The more details around the error are (nothing after this in logs):
[DEBUG] Native call tabs.open with task.params: {"url":"http://10.0.0.70:3000/oauth2/authorize?response_type=token&client_id=123&redirect_url=http://www.diveboatbuddy.com/oauth2/complete","pattern":"^http://www.diveboatbuddy.com/oauth2/complete.*$","title":"Authorizing"}
[INFO] Displaying modal view.
[DEBUG] Returned: {"content":null,"callid":"0F7BA94D-08AD-439D-B44F-80BB22540CD4","status":"success"}
[DEBUG] Native call logging.log with task.params: {"message":"[FORGE] 'Successfully subscribed for push notifications'","level":20}
[INFO] [FORGE] 'Successfully subscribed for push notifications'
[DEBUG] Returned: {"content":null,"callid":"030EF36D-C17F-42E8-8F9E-0221A40153D1","status":"success"}
[INFO] subView load http://10.0.0.70:3000/users
So it looks like the server has redirected correctly, but the trigger.io app isn't rendering the new server page.
adb logcat output of the problem:
D/Forge ( 394): Returned: {"content":null,"callid":"03F62CF7-8B33-425C-ABD5-2BA64565B789","status":"success"}
D/dalvikvm( 394): GC_EXTERNAL_ALLOC freed 349 objects / 24336 bytes in 41ms
I/Forge ( 394): subView load http://10.0.0.70:3000/users
D/AndroidRuntime( 394): Shutting down VM
W/dalvikvm( 394): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 394): FATAL EXCEPTION: main
E/AndroidRuntime( 394): java.lang.NoSuchMethodError: android.webkit.WebView.removeJavascriptInterface
E/AndroidRuntime( 394): at io.trigger.forge.android.modules.tabs.ModalView$2$3.shouldOverrideUrlLoading(ModalView.java:310)
E/AndroidRuntime( 394): at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:216)
E/AndroidRuntime( 394): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:323)
E/AndroidRuntime( 394): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 394): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 394): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 394): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 394): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 394): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 394): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 394): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 59): Force finishing activity io.trigger.forge1979a236289211e2bbe612313d31f141/io.trigger.forge.android.core.ForgeActivity
I/ARMAssembler( 59): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x3446c0:0x34477c] in 5998000 ns
W/ActivityManager( 59): Activity pause timeout for HistoryRecord{43f928a8 io.trigger.forge1979a236289211e2bbe612313d31f141/io.trigger.forge.android.core.ForgeActivity}
I/Process ( 394): Sending signal. PID: 394 SIG: 9
I/ActivityManager( 59): Process io.trigger.forge1979a236289211e2bbe612313d31f141 (pid 394) has died.
W/ActivityManager( 59): Scheduling restart of crashed service io.trigger.forge1979a236289211e2bbe612313d31f141/com.parse.PushService in 5000ms
I/WindowManager( 59): WIN DEATH: Window{44002988 io.trigger.forge1979a236289211e2bbe612313d31f141/io.trigger.forge.android.core.ForgeActivity paused=false}
I/ActivityManager( 59): Start proc io.trigger.forge1979a236289211e2bbe612313d31f141 for service io.trigger.forge1979a236289211e2bbe612313d31f141/com.parse.PushService: pid=422 uid=10036 gids={1015, 3003}
Has anyone come across this issue. Is there a work around or a bug?
This was fixed in v1.4.34 of the Trigger.io platform: http://docs.trigger.io/en/v1.4/release-notes.html#v1-4-34.
I have an android app that gets an HTTP response from a webservice, which I process into an array of strings. I than try to display those strings in a ListView. they do not need to be clicked for any action, just displayed and be scroll-able.
When ran, Everything gets done ok, but when I try to scroll down beyond the amount of items that i have to show (because there are no more strings to display on list) I get a NullPointerException. Obviously I must be doing something wrong.
I don't quite get it. I've written a similar example as a test and it works just fine. the list in the example just scrolls and stops when there are no more items to show. The only difference I can think of is that on the original app the array gets created on a thread, and than the thread runs a runnable using a handler to display the list on the gui.
when the thread that fetches the strings and orders them to the array to display finishes, he runs this code using a handler:
scoreList = (ListView) findViewById(R.id.scorelist);
ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,scoreResult);
scoreList.setAdapter(myAdapter);
than the app crashes when trying to scroll lower than the bottom. this is the error from adb logcat:
D/AndroidRuntime( 864): Shutting down VM
W/dalvikvm( 864): threadid=1: thread exiting with uncaught exception (group=0x4
001d800)
E/AndroidRuntime( 864): FATAL EXCEPTION: main
E/AndroidRuntime( 864): java.lang.NullPointerException
E/AndroidRuntime( 864): at android.widget.ArrayAdapter.createViewFromRes
ource(ArrayAdapter.java:355)
E/AndroidRuntime( 864): at android.widget.ArrayAdapter.getView(ArrayAdap
ter.java:323)
E/AndroidRuntime( 864): at android.widget.AbsListView.obtainView(AbsList
View.java:1294)
E/AndroidRuntime( 864): at android.widget.ListView.makeAndAddView(ListVi
ew.java:1727)
E/AndroidRuntime( 864): at android.widget.ListView.fillDown(ListView.jav
a:652)
E/AndroidRuntime( 864): at android.widget.ListView.fillGap(ListView.java
:623)
E/AndroidRuntime( 864): at android.widget.AbsListView.trackMotionScroll(
AbsListView.java:2944)
E/AndroidRuntime( 864): at android.widget.AbsListView.onTouchEvent(AbsLi
stView.java:2065)
E/AndroidRuntime( 864): at android.widget.ListView.onTouchEvent(ListView
.java:3315)
E/AndroidRuntime( 864): at android.view.View.dispatchTouchEvent(View.jav
a:3766)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:897)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:936)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:936)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:936)
E/AndroidRuntime( 864): at com.android.internal.policy.impl.PhoneWindow$
DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
E/AndroidRuntime( 864): at com.android.internal.policy.impl.PhoneWindow.
superDispatchTouchEvent(PhoneWindow.java:1107)
E/AndroidRuntime( 864): at android.app.Activity.dispatchTouchEvent(Activ
ity.java:2086)
E/AndroidRuntime( 864): at com.android.internal.policy.impl.PhoneWindow$
DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
E/AndroidRuntime( 864): at android.view.ViewRoot.handleMessage(ViewRoot.
java:1785)
E/AndroidRuntime( 864): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 864): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 864): at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime( 864): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 864): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 864): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 864): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime( 864): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 59): Force finishing activity memo.ori.friend/.Highscores
W/ActivityManager( 59): Activity pause timeout for HistoryRecord{4503fed0 memo
.ori.friend/.Highscores}
W/WindowManager( 59): No window to dispatch pointer action 1
W/ActivityManager( 59): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 59): Activity idle timeout for HistoryRecord{45023af0 memo.
ori.friend/.MemoFriendActivity}
D/dalvikvm( 261): GC_EXPLICIT freed 45 objects / 2128 bytes in 108ms
W/ActivityManager( 59): Activity destroy timeout for HistoryRecord{4503fed0 me
mo.ori.friend/.Highscores}
D/SntpClient( 59): request time failed: java.net.SocketException: Address fami
ly not supported by protocol
I/Process ( 864): Sending signal. PID: 864 SIG: 9
I/ActivityManager( 59): Process memo.ori.friend (pid 864) has died.
I/WindowManager( 59): WIN DEATH: Window{45077ce0 memo.ori.friend/memo.ori.frie
nd.MemoFriendActivity paused=false}
I/WindowManager( 59): WIN DEATH: Window{4507cf60 memo.ori.friend/memo.ori.frie
nd.Highscores paused=false}
I/UsageStats( 59): Unexpected resume of com.android.launcher while already res
umed in memo.ori.friend
W/InputManagerService( 59): Got RemoteException sending setActive(false) notif
ication to pid 864 uid 10044
W/IInputConnectionWrapper( 126): showStatusIcon on inactive InputConnection
D/SntpClient( 59): request time failed: java.net.SocketException: Address fami
ly not supported by protocol
When ran, Everything gets done ok, but when I try to scroll down
beyond the amount of items that i have to show (because there are no
more strings to display on list) I get a NullPointerException.
Obviously I must be doing something wrong.
That exception comes from having null values in the list/array(scoreResult) that you pass to the ArrayAdapter. This is because the ArrayAdapter will call, by default,(in it's getView method which is responsible for building the list's rows) the toString method on each item from the data list if the type of that item isn't a CharSequence(you have String), to obtain a text representation of that item to show in the row.
So check the scoreResult list/array and make sure you don't have null values in it. I see you speak of an array, make sure the array is just as big as it needs for the data, if it's bigger than the data you'll have null values at its end.
request time failed: java.net.SocketException: Address fami
ly not supported by protocol
pls check what is there, somethig not good.
NullPointerException it is the beginner programmer sign: it doesn't verify the parameters and he write multiple statements in 1 line. In this case I would check the scoreResult to not be empty, but at least not null
D/AndroidRuntime(11752):
D/AndroidRuntime(11752): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(11752): CheckJNI is ON
D/dalvikvm(11752): creating instr width table
E/jdwp (11752): pipe failed
W/ProcessState(11752): Opening '/dev/binder' failed: Too many open files
D/AndroidRuntime(11752): Calling main entry com.android.commands.am.Am
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>> java.lang.NullPointerException
I/DMIC ( 1726): ---> java.lang.NullPointerException
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 31K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=7,camera
I/System.out( 1726): ***run in test i=8,cec
I/System.out( 1726): ***run in test i=9,edid
I/System.out( 1726): *****wifi state start=1
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>>
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 36K, 41% free 7474K/12551K, external 1625K/2137K, paused 57ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7474K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=10,iris
I/System.out( 1726): *****wifi state start=1
I/ActivityManager( 1491): Starting: Intent { act=com.android.camera.irison flg=0x10000000 cmp=com.ianc.apd/.testcase.cameraex.ImageCamera } from pid 1726
I/System.out( 1726): onCreate
I/System.out( 1726): onResume
I/System.out( 1726): test irist on
I/System.out( 1726): excuteCmd/sys/bus/spi/devices/spi2.0/irisstate
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Consumer closed input channel or an error occurred. events=0x8
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Channel is unrecoverably broken and will be disposed!
D/AndroidRuntime( 1726): Shutting down VM
W/dalvikvm( 1726): threadid=1: thread exiting with uncaught exception (group=0x40015560)
I/WindowManager( 1491): WINDOW DIED Window{40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera paused=false}
E/AndroidRuntime( 1726): FATAL EXCEPTION: main
E/AndroidRuntime( 1726): java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
E/AndroidRuntime( 1726): at android.view.InputChannel.nativeReadFromParcel(Native Method)
E/AndroidRuntime( 1726): at android.view.InputChannel.readFromParcel(InputChannel.java:138)
E/AndroidRuntime( 1726): at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:409)
E/AndroidRuntime( 1726): at android.view.ViewRoot.setView(ViewRoot.java:498)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime( 1726): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2170)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
E/AndroidRuntime( 1726): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1726): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1726): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1726): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1726): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 1726): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 1491): Force finishing activity com.ianc.apd/.testcase.cameraex.ImageCamera
W/ActivityManager( 1491): Activity pause timeout for HistoryRecord{4069a248 com.ianc.apd/.testcase.cameraex.ImageCamera}
Why do Consumer closed input channel or an error occurred. events=0x8 happen after many times running? That is too say, my program can run at first, but after many times, the exception happen.
I read this: Input transport and input dispatcher error on 2.3, but I have no idea how to solve it!! Who can help me?
I run my program in real device. The android version is 2.3
Update 1:
I found the root cause of Could not read input channel file descriptors from parcel.
It is E/jdwp (11752): pipe failed.
Why do create pipe failed? Because the pipe is out of the max in the system. that is to say, we create a lot of pipe or file descriptors in the system. And then we found the reason and try to modify it: My friend change the code like that in his Activity: `Original source code:
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
...
HandlerThread ht = new HandlerThread("CameraHolder");
ht.start();
mHandler = new MyHandler(ht.getLooper());
change to
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
mHandler = new MyHandler();
Those file descriptors will reduce obviously. Why? how to explain this case? And I add mHandler.removemessage this function to onPause in my Activity. And Those file descriptors also reduce obviously. why? who can explain this case for me? I am trying to understand this.
Benni05 found a solution here, by setting android:configChanges="orientation" property for activity #AndroidManifest. It work for me(where i get an error with api lvl.11 installed devices). Good luck!
it is most probably because of having a wrong xml resource file. for me i put colors in strings.xml and got this errors. then i created colors.xml and now it works.
I am creating an application that checks the installation of a package and then launches the market-place with its id.
When I try to launch market place with id of an application say com.mybrowser.android by throwing an intent android.intent.action.VIEW with url: market://details?id=com.mybrowser.android, the market place application does launches but crashes after launch.
Note: the application com.mybrowser.android doesn't exists in the market-place.
MyApplication is my application.
$ adb logcat
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=myapp.testapp/.MyApplication }
I/ActivityManager( 1030): Start proc myapp.testapp for activity myapp.testapp/.MyApplication: pid=3858 uid=10047 gids={1015, 3003}
I/MyApplication( 3858): [ Activity CREATED ]
I/MyApplication( 3858): [ Activity STARTED ]
I/MyApplication( 3858): onResume
D/dalvikvm( 1109): GC freed 6571 objects / 423480 bytes in 73ms
I/MyApplication( 3858): Pressed OK button
I/MyApplication( 3858): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.mybrowser.android
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.mybrowser.android flg=0x10000000 cmp=com.android.ven
ding/.AssetInfoActivity }
I/MyApplication( 3858): onPause
I/ActivityManager( 1030): Start proc com.android.vending for activity com.android.vending/.AssetInfoActivity: pid=3865 uid=10023 gids={3003}
I/ActivityThread( 3865): Publishing provider com.android.vending.SuggestionsProvider: com.android.vending.SuggestionsProvider
D/dalvikvm( 1030): GREF has increased to 701
I/vending ( 3865): com.android.vending.api.RadioHttpClient$1.handleMessage(): Handle DATA_STATE_CHANGED event: NetworkInfo: type: WIFI[], state: CONNECTED/CO
NNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
I/ActivityManager( 1030): Displayed activity com.android.vending/.AssetInfoActivity: 609 ms (total 7678 ms)
D/dalvikvm( 1030): GC freed 10458 objects / 676440 bytes in 128ms
I/MyApplication( 3858): [ Activity STOPPED ]
D/dalvikvm( 3865): GC freed 3538 objects / 254008 bytes in 84ms
W/dalvikvm( 3865): threadid=19: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 3865): at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime( 3865): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 3865): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 3865): at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime( 3865): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3865): at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:845)
E/AndroidRuntime( 3865): at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:831)
E/AndroidRuntime( 3865): at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime( 3865): ... 4 more
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
I/dalvikvm( 3865): threadid=7: reacting to signal 3
I/dalvikvm( 3865): Wrote stack trace to '/data/anr/traces.txt'
I/DumpStateReceiver( 1030): Added state dump to 1 crashes
D/AndroidRuntime( 3865): Shutting down VM
W/dalvikvm( 3865): threadid=3: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.NullPointerException
E/AndroidRuntime( 3865): at com.android.vending.controller.AssetInfoActivityController.getIdDeferToLocal(AssetInfoActivityController.java:637)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity.displayAssetInfo(AssetInfoActivity.java:556)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity.access$800(AssetInfoActivity.java:74)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity$LoadAssetInfoAction$1.run(AssetInfoActivity.java:917)
E/AndroidRuntime( 3865): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3865): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3865): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3865): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 3865): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3865): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3865): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 3865): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 3865): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
W/ActivityManager( 1030): Process com.android.vending has crashed too many times: killing!
D/ActivityManager( 1030): Force finishing activity com.android.vending/.AssetInfoActivity
I/dalvikvm( 3865): threadid=7: reacting to signal 3
D/ActivityManager( 1030): Force removing process ProcessRecord{44e48548 3865:com.android.vending/10023} (com.android.vending/10023)
However, when I try to launch the market place for a package that exists in the market place say com.opera.mini.android, everything works. Log for this case:
D/dalvikvm( 966): GC freed 2781 objects / 195056 bytes in 99ms
I/MyApplication( 1165): Pressed OK button
I/MyApplication( 1165): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.opera.mini.android
I/ActivityManager( 78): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.opera.mini.android flg=0x10000000 cmp=com.android.vending/.AssetInfoActivity }
I/AndroidRuntime( 1165): AndroidRuntime onExit calling exit(0)
I/WindowManager( 78): WIN DEATH: Window{44c72308 myapp.testapp/myapp.testapp.MyApplication paused=true}
I/ActivityManager( 78): Process myapp.testapp (pid 1165) has died.
I/WindowManager( 78): WIN DEATH: Window{44c72958 myapp.testapp/myapp.testapp.MyApplication paused=false}
D/dalvikvm( 78): GC freed 31778 objects / 1796368 bytes in 142ms
I/ActivityManager( 78): Displayed activity com.android.vending/.AssetInfoActivity: 214 ms (total 22866 ms)
W/KeyCharacterMap( 978): No keyboard for id 65540
W/KeyCharacterMap( 978): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
V/RenderScript_jni( 966): surfaceCreated
V/RenderScript_jni( 966): surfaceChanged
V/RenderScript( 966): setSurface 480 762 0x573430
D/ViewFlipper( 966): updateRunning() mVisible=true, mStarted=true, mUserPresent=true, mRunning=true
D/dalvikvm( 978): GC freed 10065 objects / 624440 bytes in 95ms
Any ideas?
I am having similar problem when trying to open a detail page in Market app using "market://details?id=pname:org.rabold.android.puzzleblox" URL from an application.
I can create a shortcut using AnyCut like this:
action: android.intent.action.VIEW
data: market://details?id=pname:org.rabold.android.puzzleblox
type:
then it works fine.
However, if I create an Android application with a button to launch Market with the same Uri as above, then I get an error in Market app like this: "Attention: A server error has occurred. Retry, or cancel and return to the previous screen."
The code of my button's listener looks like this:
okButton = (Button) findViewById(R.id.okButton);
okButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=pname:org.rabold.android.puzzleblox"));
//Uri.parse("market://search?q=pname:org.rabold.android.puzzleblox"));
startActivity(intent);
}
});
Note in the above code, if I use 'search' instead of 'details' then it works. I'd like to use 'details' instead of 'search' because I know that my app will be available on Market when it's done. Thanks.
Update!:
Do not use "pname:"
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
Works perfectly.
per:
http://developer.android.com/distribute/googleplay/promote/linking.html#android-app
☮ ♥ ☺
thnx Daniel, I can confirm that your solution is working fine on device.
#TPham: please try with correct url (append id only),
passing correct id also working fine, see example below;
static final String APP_MARKET_URL = "market://details?id=com.wareninja.android.fotolicke";
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse(APP_MARKET_URL));
startActivity(intent);
instead of launching with the exact ID, you can try doing it by searching by the package.
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse("market://search?q=pname:com.package.package2.package3"));
startActivity(intent);