Android开发之--从app中跳转到淘宝店铺
来源:互联网 发布:激活 知乎 编辑:程序博客网 时间:2024/05/02 04:38
首先、一个工具类 方法,检测该包名下的应用是否存在
public static boolean checkPackage(Context context ,String packageName){ if (packageName == null || "".equals(packageName)) return false; try{ context.getPackageManager().getApplicationInfo(packageName, PackageManager .GET_UNINSTALLED_PACKAGES); return true; }catch (PackageManager.NameNotFoundException e){ return false; }}
然后就是在需要的地方调用
以下是打开淘宝的方法
调用工具类,判断该包名下的应用是否存在,如果存在,则跳转,如果不存在,则打开网页版默认地址
private void openTaobaoShopping() { if (DeviceUtil.checkPackage(this, "com.taobao.taobao")) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW");// https://detail.tmall.com/item.htm?id=535823983028&spm=a21bo.7932663.item.2.0mvUrk&scm=1007.13596.65361.100200300000014 String url = "taobao://shop.m.taobao.com/shop/shop_index.htm?shop_id=131259851&spm=a230r.7195193.1997079397.8.Pp3ZMM&point"; Uri uri = Uri.parse(url); intent.setData(uri); startActivity(intent); } else { WebViewActivity.open(MainActivity.this, "https://shop131259851.taobao.com/?spm=a230r.7195193.1997079397.8.Pp3ZMM"); } }
接下来 是WebViewActivity中的open方法 它是打开网页版路径:
public static void open(Context context,String url){ Intent intent = new Intent(); intent.setClass(context,WebViewActivity.class); intent.putExtra("webUrl",url); context.startActivity(intent);}
其中 webviewactivity中 布局只是一个webview
<WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" android:fadingEdge="none" android:visibility="invisible" android:fadingEdgeLength="0dp" android:scrollbars="none" />
0 0
- Android开发之--从app中跳转到淘宝店铺
- android app跳转淘宝客户端店铺
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- 从App内跳转到淘宝天猫详情页面
- Android 从网页中跳转到APP并传递数据
- Android 从网页中跳转到本地App
- 让app中链接跳转跳转到淘宝店主页,如果存在淘宝app
- 新开淘宝店铺如何从0到1
- 新开淘宝店铺如何从0到1
- 【JavaScript】中关于null和undefined的研究
- 手机号码-正则
- 抽象类与接口的区别
- 3D Touch开发
- 代码规范之 break,continue,return 关键字的使用
- Android开发之--从app中跳转到淘宝店铺
- V4L2 ,VIDIOC_DQBUF,Invalid argument
- Swift3中的新特性
- 如何理解公钥加密/私钥解密
- OpenCV SITF 特征提取 FeatureDetector对象函数detect运行报错解决方案
- group by
- 真机调试出现Could not launch "FeedMeWorms" failed to get the task for process 3118
- 两个Xcode使用低版本SDK进行自动打包
- java POI设置Excel单元格的边框样式