Android中的向上导航无效。我想要它做的就是回去。但是每次我点击后退按钮都会关闭应用程序。我跟着android开发者。我的错误日志甚至没有说anthing有用,所以我不知道为什么会这样。我的第一个主要视图是谷歌地图活动,我的第二个视图是一个空白活动,其上面有一个列表视图。
这是我的错误日志
03-14 11:20:56.261 19816-19816/com.example.anusha.app I/SELinux Function:selinux_android_load_priority , priority [2] , priority version is VE=SEPF_SAMSUNG-SGH-I337_4.4.4_0032
03-14 11:20:56.261 19816-19816/com.example.anusha.app E/dalvikvm﹕ >>>>> Normal User
03-14 11:20:56.261 19816-19816/com.example.anusha.app E/dalvikvm﹕ >>>>> com.example.anusha.app [ userId:0 | appId:10250 ]
03-14 11:20:56.271 19816-19816/com.example.anusha.app D/dalvikvm﹕ Late-enabling CheckJNI
03-14 11:20:56.412 19816-19816/com.example.anusha.app I/x﹕ Making Creator dynamically
03-14 11:20:56.472 19816-19816/com.example.anusha.app I/Google Maps Android API﹕ Google Play services client version: 6587000
03-14 11:20:56.472 19816-19816/com.example.anusha.app I/Google Maps Android API﹕ Google Play services package version: 6776038
03-14 11:20:57.453 19816-19816/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4226K, 23% free 20774K/26904K, paused 41ms, total 42ms
03-14 11:20:57.543 19816-19816/com.example.anusha.app I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.ew.c
03-14 11:20:57.543 19816-19816/com.example.anusha.app W/dalvikvm﹕ VFY: unable to resolve virtual method 441: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
03-14 11:20:57.543 19816-19816/com.example.anusha.app D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000f
03-14 11:20:57.613 19816-19957/com.example.anusha.app W/ActivityThread﹕ ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
03-14 11:20:57.673 19816-19816/com.example.anusha.app D/AbsListView﹕ Get MotionRecognitionManager
03-14 11:20:57.823 19816-19816/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 1176K, 20% free 21645K/26904K, paused 53ms, total 53ms
03-14 11:20:57.983 19816-19816/com.example.anusha.app D/Activity﹕ #1 setTransGradationModeColor false
03-14 11:20:58.023 19816-19816/com.example.anusha.app I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: (CL3869936)
OpenGL ES Shader Compiler Version: 17.01.11.SPL
Build Date: 01/17/14 Fri
Local Branch:
Remote Branch:
Local Patches:
Reconstruct Branch:
03-14 11:20:58.143 19816-19816/com.example.anusha.app D/OpenGLRenderer﹕ Enabling debug mode 0
03-14 11:20:58.353 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 1659K, 19% free 22025K/26904K, paused 72ms, total 73ms
03-14 11:20:58.614 19816-19972/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 1364K, 18% free 22317K/26904K, paused 48ms, total 48ms
03-14 11:20:58.744 19816-19972/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 91K, 17% free 22589K/26904K, paused 45ms, total 45ms
03-14 11:20:58.804 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 367K, 16% free 23090K/27344K, paused 35ms, total 35ms
03-14 11:20:59.154 19816-19972/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 11145K, 33% free 27756K/41368K, paused 47ms, total 47ms
03-14 11:20:59.234 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4822K, 44% free 23455K/41368K, paused 34ms, total 34ms
03-14 11:20:59.244 19816-19981/com.example.anusha.app I/dalvikvm-heap﹕ Grow heap (frag case) to 30.763MB for 4194320-byte allocation
03-14 11:20:59.374 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4367K, 44% free 23465K/41368K, paused 35ms, total 35ms
03-14 11:20:59.374 19816-19981/com.example.anusha.app I/dalvikvm-heap﹕ Grow heap (frag case) to 30.773MB for 4194320-byte allocation
03-14 11:20:59.495 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4234K, 44% free 23466K/41368K, paused 46ms, total 46ms
03-14 11:20:59.495 19816-19981/com.example.anusha.app I/dalvikvm-heap﹕ Grow heap (frag case) to 30.774MB for 4194320-byte allocation
03-14 11:20:59.595 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4234K, 44% free 23466K/41368K, paused 36ms, total 36ms
03-14 11:20:59.595 19816-19981/com.example.anusha.app I/dalvikvm-heap﹕ Grow heap (frag case) to 30.774MB for 4194320-byte allocation
03-14 11:20:59.705 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4240K, 44% free 23458K/41368K, paused 42ms, total 42ms
03-14 11:20:59.705 19816-19981/com.example.anusha.app I/dalvikvm-heap﹕ Grow heap (frag case) to 30.766MB for 4194320-byte allocation
03-14 11:20:59.805 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 4233K, 44% free 23459K/41368K, paused 40ms, total 40ms
03-14 11:20:59.805 19816-19981/com.example.anusha.app I/dalvikvm-heap﹕ Grow heap (frag case) to 30.767MB for 4194320-byte allocation
03-14 11:21:00.075 19816-19981/com.example.anusha.app D/dalvikvm﹕ GC_FOR_ALLOC freed 6133K, 44% free 23465K/41368K, paused 79ms, total 79ms
03-14 11:21:12.057 19816-19816/com.example.anusha.app I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
03-14 11:21:12.057 19816-19816/com.example.anusha.app W/dalvikvm﹕ VFY: unable to resolve virtual method 11751: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
03-14 11:21:12.057 19816-19816/com.example.anusha.app D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
03-14 11:21:12.067 19816-19816/com.example.anusha.app I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
03-14 11:21:12.067 19816-19816/com.example.anusha.app W/dalvikvm﹕ VFY: unable to resolve virtual method 11757: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
03-14 11:21:12.067 19816-19816/com.example.anusha.app D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
03-14 11:21:12.067 19816-19816/com.example.anusha.app I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
03-14 11:21:12.067 19816-19816/com.example.anusha.app W/dalvikvm﹕ VFY: unable to resolve virtual method 9402: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
03-14 11:21:12.067 19816-19816/com.example.anusha.app D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
03-14 11:21:12.067 19816-19816/com.example.anusha.app I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
03-14 11:21:12.067 19816-19816/com.example.anusha.app W/dalvikvm﹕ VFY: unable to resolve virtual method 537: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
03-14 11:21:12.067 19816-19816/com.example.anusha.app D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-14 11:21:12.067 19816-19816/com.example.anusha.app I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
03-14 11:21:12.067 19816-19816/com.example.anusha.app W/dalvikvm﹕ VFY: unable to resolve virtual method 559: Landroid/content/res/TypedArray;.getType (I)I
03-14 11:21:12.067 19816-19816/com.example.anusha.app D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-14 11:21:12.107 19816-19816/com.example.anusha.app D/AbsListView﹕ Get MotionRecognitionManager
03-14 11:21:12.117 19816-19816/com.example.anusha.app D/Activity﹕ #1 setTransGradationModeColor false
03-14 11:21:12.637 19816-19816/com.example.anusha.app D/AbsListView﹕ onDetachedFromWindow
03-14 11:21:14.019 19816-19816/com.example.anusha.app V/recreate activity﹕ shouldUpRecreateTask = false
03-14 11:21:14.699 19816-19816/com.example.anusha.app D/AbsListView﹕ onDetachedFromWindow
03-14 11:23:18.887 21337-21337/com.example.anusha.app I/SELinux﹕ Function: selinux_android_load_priority , priority [2] , priority version is VE=SEPF_SAMSUNG-SGH-I337_4.4.4_0032
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.button:
Add();
return true;
case android.R.id.home:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.
TaskStackBuilder.create(this)
// Add all of this activity's parents to the back stack
.addNextIntentWithParentStack(upIntent)
// Navigate up to the closest parent
.startActivities();
} else {
// This activity is part of this app's task, so simply
// navigate up to the logical parent activity.
upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
NavUtils.navigateUpTo(this, upIntent);
Log.v("recreate activity", "shouldUpRecreateTask = false");
}
return true;
}
return super.onOptionsItemSelected(item);
}
这是我的清单
<activity
android:name=".SilentGeofence"
android:label="@string/title_activity_silent_geofence"
android:parentActivityName=".AddressList" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".AddressList" />
</activity>
答案 0 :(得分:1)
Button button2 = (Button) findViewById(R.id.button2); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v ) { Intent intent = new Intent(MapsActivity.this, AddressList.class); startActivity(intent);} }); }
删除完成并且它将起作用
答案 1 :(得分:0)
如果您只想点击操作栏主页按钮然后返回,请将case android.R.id.home:
中的代码替换为:
super.onBackPressed();
break;
这将重新创建后退按钮。