stackBuilder.addParentStack(ResultActivity.class);
nb.setParentActivity(main2)
stackBuilder.addParentStack(pActivity.getClass());
** Activity (main) Create, isFirst = true **
Class returned class java.lang.Class
main_activity_create (java line: 248)
java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{barxdroid.nbtest/java.lang.Class}
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:197)
at barxdroid.NotificationBuilder.NotificationBuilder.Notify(NotificationBuilder.java:116)
at barxdroid.nbtest.main._activity_create(main.java:248)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at barxdroid.nbtest.main.afterFirstLayout(main.java:85)
at barxdroid.nbtest.main.access$100(main.java:16)
at barxdroid.nbtest.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4575)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{barxdroid.nbtest/java.lang.Class}
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:223)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:264)
at android.support.v4.app.NavUtils.getParentActivityIntent(NavUtils.java:211)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:190)
... 17 more
java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{barxdroid.nbtest/java.lang.Class}
return pActivity.getClass().toString();
stackBuilder.addParentStack(ba.activity.getClass());
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 246)
java.lang.NullPointerException
at barxdroid.NotificationBuilder.NotificationBuilder.Notify(NotificationBuilder.java:116)
at barxdroid.nbtest.main._activity_create(main.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at barxdroid.nbtest.main.afterFirstLayout(main.java:85)
at barxdroid.nbtest.main.access$100(main.java:16)
at barxdroid.nbtest.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4575)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
if(nActivity != null) {
Intent resultIntent = new Intent(Common.getComponentIntent(ba, nActivity));
if(pActivity != null) {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(ba.context);
stackBuilder.addParentStack(pActivity.getClass());
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
((Builder)getObject()).setContentIntent(resultPendingIntent);
}
}
That's expected behaviour. Try getClass().getName() to see the actual class.And all it ever seems to return is 'java.lang.Class'
stackBuilder.addParentStack(pActivity.getClass());
LogCat connected to: SH0BCRT05610
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
java.lang.Class
main_activity_create (java line: 250)
java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{barxdroid.nbtest/java.lang.Class}
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:197)
at barxdroid.NotificationBuilder.NotificationBuilder.Notify(NotificationBuilder.java:195)
at barxdroid.nbtest.main._activity_create(main.java:250)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at barxdroid.nbtest.main.afterFirstLayout(main.java:85)
at barxdroid.nbtest.main.access$100(main.java:16)
at barxdroid.nbtest.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4575)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{barxdroid.nbtest/java.lang.Class}
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:223)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:264)
at android.support.v4.app.NavUtils.getParentActivityIntent(NavUtils.java:211)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:190)
... 17 more
java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{barxdroid.nbtest/java.lang.Class}
BA.Log(pActivity.getClass().getName());
It's typically obtuse (I find the Android documentation is usually totally unhelpful) but the standard Basic4android manifest doesn't seem to have a <meta-data> tag so maybe it's complaining about the lack of a name attribute in the meta-data.Add the activity parent chain as specified by manifest <meta-data> elements to the task stack builder.
public void Test(BA ba, String ActModName)
{
String PN = BA.packageName;
TaskStackBuilder stackBuilder = TaskStackBuilder.create(ba.context);
stackBuilder.addParentStack(new ComponentName(PN, PN + "." + ActModName.toLowerCase(BA.cul)));
}
This is a wild guess and you may have tried this already! The Android docs for TaskStackBuilder.addParentStack(Class<?> sourceActivityClass) say
It's typically obtuse (I find the Android documentation is usually totally unhelpful) but the standard Basic4android manifest doesn't seem to have a <meta-data> tag so maybe it's complaining about the lack of a name attribute in the meta-data.
Here's something you can try. I get no error with this code (ActModName is the activity module name as it appears in B4A, e.g. "Main" for the main activity):
B4X:public void Test(BA ba, String ActModName) { String PN = BA.packageName; TaskStackBuilder stackBuilder = TaskStackBuilder.create(ba.context); stackBuilder.addParentStack(new ComponentName(PN, PN + "." + ActModName.toLowerCase(BA.cul))); }
ComponentInfo{barxdroid.nbtest/barxdroid.nbtest.main2}
ComponentName cn = new ComponentName(pn, "." + pActivity.toLowerCase((BA.cul)));
** Activity (main) Create, isFirst = true **
-3
java.lang.String
ComponentInfo{barxdroid.nbtest/.main2}
main_activity_create (java line: 250)
java.lang.NoSuchMethodError: android.support.v4.app.TaskStackBuilder.addParentStack
at barxdroid.NotificationBuilder.NotificationBuilder.Notify(NotificationBuilder.java:201)
at barxdroid.nbtest.main._activity_create(main.java:250)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at barxdroid.nbtest.main.afterFirstLayout(main.java:85)
at barxdroid.nbtest.main.access$100(main.java:16)
at barxdroid.nbtest.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4575)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
That's expected behaviour. Try getClass().getName() to see the actual class.
stackBuilder.addParentStack(resultActivity.class);
stackBuilder.addParentStack("resultActivity.class");
I didn't think you could use it, I assumed that you just wanted a way to confirm that the object that you were trying to use was of the correct Class.Cannot use .getName() for this as it returns a string.
Reporting back as promised.
Added the code you posted Informatix and got an NoSucgMethodError.
So I tried tweaking the code to
B4X:ComponentName cn = new ComponentName(pn, "." + pActivity.toLowerCase((BA.cul)));
Sill get the same error but as you can see from the log, the name now looks right.
You have a problem with the support library. "NoSuchMethodError" means the library does not contain a method "addParentStack", but the documentation and my own test prove that it is a method of TaskStackBuilder, without any doubt, and it is included in the support library. So you have a problem with your library. You should get the latest version.
No, it looks wrong. The right name is the one you got first.
Are you saying there is a problem with the support library file I am using?
it is the one included in latest SDK. The addParentStack method comes up (and was selected) from the auto-complete in eclipse. So, you saying I should try and download another copy from somewhere?
Thanks
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?