我有MainActivity上有一个片段,当用户点击片段时,用户会导航到另一个片段,在最后一个片段上有一个按钮来启动谷歌地图导航,这是代码:
@Override
public void onClick(View v) {
String url = "https://www.google.com/maps/dir/?api=1&destination=-17.174498,12.634206";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
getActivity().overridePendingTransition(R.anim.slide_up_in, R.anim.slide_up_out);
}
问题是,在地图启动后,我希望用户在按下back时返回到我的应用程序,而不是Launcher。
有没有办法做到这一点。
这是我的完整代码:
主体活动
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.replace(R.id.fragment_container, new SplashFragment())
.commit();
}
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_splash, container, false);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Transition transition = new Fade(Visibility.MODE_IN);
transition.setDuration(400);
Fragment fragment = MapsFragment.newInstance();
// set transition animation
fragment.setEnterTransition(transition);
fragment.setAllowEnterTransitionOverlap(true);
fragment.setAllowReturnTransitionOverlap(true);
// add second fragment by replacing first
getFragmentManager().beginTransaction()
.replace(R.id.fragment_container, fragment)
.addToBackStack(null)
.commit();
}
});
return view;
}
原木
08-31 21:45:41.072 1536-1536/? E/Zygote: v2
08-31 21:45:41.072 1536-1536/? I/libpersona: KNOX_SDCARD checking this for 10319
08-31 21:45:41.072 1536-1536/? I/libpersona: KNOX_SDCARD not a persona
08-31 21:45:41.072 1536-1536/? W/SELinux: Function: selinux_compare_spd_ram, index[1], priority [2], priority version is VE=SEPF_SECMOBILE_6.0.1_0034
08-31 21:45:41.082 1536-1536/? E/Zygote: accessInfo : 0
08-31 21:45:41.082 1536-1536/? W/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.nyongrand.ibnuratihinvitation
08-31 21:45:41.082 1536-1536/? I/art: Late-enabling -Xcheck:jni
08-31 21:45:41.152 1536-1536/com.nyongrand.ibnuratihinvitation W/ResourcesManager: Resource getTopLevelResources for package com.nyongrand.ibnuratihinvitationoverlayDirs =Null
08-31 21:45:41.342 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.592 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.652 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.712 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.782 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.842 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.902 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:41.972 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:42.032 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:42.092 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:42.162 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=speed --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.nyongrand.ibnuratihinvitation-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.nyongrand.ibnuratihinvitation-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
08-31 21:45:42.162 1536-1536/com.nyongrand.ibnuratihinvitation W/System: ClassLoader referenced unknown path: /data/app/com.nyongrand.ibnuratihinvitation-2/lib/arm64
08-31 21:45:42.172 1536-1536/com.nyongrand.ibnuratihinvitation I/InstantRun: starting instant run server: is main process
08-31 21:45:42.322 1536-1536/com.nyongrand.ibnuratihinvitation W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-31 21:45:42.532 1536-1705/com.nyongrand.ibnuratihinvitation I/zzbx: Making Creator dynamically
08-31 21:45:42.542 1536-1705/com.nyongrand.ibnuratihinvitation W/ResourcesManager: Resource getTopLevelResources for package com.google.android.gmsoverlayDirs =Null
08-31 21:45:42.602 1536-1708/com.nyongrand.ibnuratihinvitation I/OpenGLRenderer: Initialized EGL, version 1.4
08-31 21:45:42.652 1536-1542/com.nyongrand.ibnuratihinvitation W/art: Suspending all threads took: 6.789ms
08-31 21:45:42.662 1536-1705/com.nyongrand.ibnuratihinvitation W/ResourcesManager: Resource getTopLevelResources for package com.google.android.gmsoverlayDirs =Null
08-31 21:45:42.672 1536-1536/com.nyongrand.ibnuratihinvitation I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@9e7090d time:16980299
08-31 21:45:42.712 1536-1705/com.nyongrand.ibnuratihinvitation I/Google Maps Android API: Google Play services client version: 11020000
08-31 21:45:42.732 1536-1705/com.nyongrand.ibnuratihinvitation I/Google Maps Android API: Google Play services package version: 11509440
08-31 21:45:43.322 1536-1705/com.nyongrand.ibnuratihinvitation E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@de4bdd2
08-31 21:45:43.322 1536-1705/com.nyongrand.ibnuratihinvitation E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@ea6fea3
08-31 21:45:43.322 1536-1705/com.nyongrand.ibnuratihinvitation E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@ea6fea3
08-31 21:45:43.382 1536-1705/com.nyongrand.ibnuratihinvitation W/System.err: mkdir failed: EEXIST (File exists) : /storage/emulated/0/Android/data/com.nyongrand.ibnuratihinvitation/cache/debug
08-31 21:45:43.382 1536-1705/com.nyongrand.ibnuratihinvitation W/System.err: mkdir failed: EEXIST (File exists) : /storage/emulated/0/Android/data/com.nyongrand.ibnuratihinvitation/cache
08-31 21:45:43.432 1536-1793/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:43.432 1536-1793/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:43.442 1536-1793/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 85 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:45:43.842 1536-1793/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 79 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:45:44.002 1536-1793/com.nyongrand.ibnuratihinvitation I/qtaguid: Untagging socket 85
08-31 21:45:57.962 1536-1536/com.nyongrand.ibnuratihinvitation I/Google Maps Android API: Google Play services package version: 11509440
08-31 21:45:58.102 1536-1795/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:58.102 1536-1795/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:58.102 1536-1795/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 85 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:45:58.192 1536-1796/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:58.192 1536-1796/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:58.192 1536-1796/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 58 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:45:58.282 1536-1795/com.nyongrand.ibnuratihinvitation I/qtaguid: Untagging socket 85
08-31 21:45:58.452 1536-1796/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 61 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:45:58.682 1536-1796/com.nyongrand.ibnuratihinvitation I/qtaguid: Untagging socket 58
08-31 21:45:59.352 1536-1797/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:59.352 1536-1797/com.nyongrand.ibnuratihinvitation I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
08-31 21:45:59.362 1536-1797/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 93 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:46:00.182 1536-3184/com.nyongrand.ibnuratihinvitation W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
08-31 21:46:00.202 1536-3184/com.nyongrand.ibnuratihinvitation I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
08-31 21:46:00.202 1536-3184/com.nyongrand.ibnuratihinvitation I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 4
08-31 21:46:00.222 1536-3184/com.nyongrand.ibnuratihinvitation W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000014/n/arm64-v8a
08-31 21:46:00.232 1536-3184/com.nyongrand.ibnuratihinvitation W/ResourcesManager: Resource getTopLevelResources for package com.google.android.gmsoverlayDirs =Null
08-31 21:46:01.522 1536-1797/com.nyongrand.ibnuratihinvitation I/qtaguid: Tagging socket 103 with tag 3000110100000000{805310721,0} uid -1, pid: 1536, getuid(): 10319
08-31 21:46:01.922 1536-1797/com.nyongrand.ibnuratihinvitation I/qtaguid: Untagging socket 93
您必须向意图添加标志,如下所示
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(intent);
getActivity().overridePendingTransition(R.anim.slide_up_in, R.anim.slide_up_out);
请试着告诉我。
问题内容: 当我尝试在片段上显示地图时,它返回空指针异常。我已将所有权限添加到清单中。我将片段文件附加为其XML文件和log cat Chatffragment.java 其XML LOGCAT 第55和70行是googleMap = mapFrag.getMap(); initilizeMap(); 问题答案: 您必须等到地图加载完毕…。 编辑 检查编辑代码,使用ChildFragmentMan
我在做一个从传感器收集数据的应用程序。每次传感器发送数据时,地图上都会放置一个新的标记。当我按后退,然后恢复地图活动,所有的标记都消失了。在恢复活动时,是否有方法保存和恢复每个唯一的标记及其唯一的标记选项(title、snippet、LatLng)?
所以我看到了一个特殊的例外,我敢肯定的是谷歌地图的绘图代码。 我有一个片段,在那里我以编程方式添加了一个支持地图片段,然后我在其中操纵谷歌地图实例。 这是stacktrace: 我无法可靠地复制它(尽管这种情况经常发生),我已经查看了ReadWriteDirectByteBuffer和ShortToByteBufferAdapter,但没有任何东西突然出现在我面前。 有什么想法吗?
我认为问题是我需要添加构建提示。我可以找到在哪里添加他们,但我不确定他们应该是什么格式。我也不知道要补充什么。我想我发现了一个帖子,说我需要添加Android.xapplication=Android:value=“Your Key”/>Android.xPermissions= 但我不确定构建提示条目表单中的格式是什么
LSV默认的对谷歌影像进行了加载,如果需要加载其他的谷歌地图数据,可以通过LSV中直接点击即可加载。
问题内容: 我为具有不同元数据的活动设置了一些别名。 在此元数据中,我设置了片段的名称,然后通过反射将其加载。 我不知道这是否是一个“干净”的解决方案,尽管通过使用Fragments并将功能放入内部,我只具有一个SuperActivity和2个Empty SubActivity来指定清单中的每个。 现在的问题是:我可以通过意图启动别名吗?无法工作,因为我找不到通过意图调用来设置元数据的方法。 我需