H5做的商城客户端,效果很不错


H5做的商城客户端,效果和android原生客户端没多大区别,现在h5是越来越火了,
android的小伙伴们又遇到一个新的挑战了。本项目只能学习一下WebViewActivity使用,
但是由于js看不到,所以补发看到里面的方法,
主要代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
ButterKnife.bind(this);
String url = getIntent().getStringExtra(EXTRA_URL);
mWebView.setWebViewClient(new WebViewClient());
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl(url);
setupActionBar(url);
}

还有就是CustomTabActivityHelper类封装了
/**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView
*
* @param activity The host activity
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available
* @param uri the Uri to be opened
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available
*/
public static void openCustomTab(Activity activity,
CustomTabsIntent customTabsIntent,
Uri uri,
CustomTabFallback fallback) {
String packageName = CustomTabsHelper.getPackageNameToUse(activity);

//If we cant find a package name, it means there's no browser that supports
//Chrome Custom Tabs installed. So, we fallback to the webview
if (packageName == null) {
if (fallback != null) {
fallback.openUri(activity, uri);
}
} else {
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
}
}

/**
* Unbinds the Activity from the Custom Tabs Service
* @param activity the activity that is connected to the service
*/
public void unbindCustomTabsService(Activity activity) {
if (mConnection == null) return;
activity.unbindService(mConnection);
mClient = null;
mCustomTabsSession = null;
}

运行效果:

  • H5做的商城客户端,效果很不错

相关代码

  • H5做的商城客户端,效果很不错

  • listview实现各种版面设计功能

  • GankApp 侧滑和title修改颜色的完整项目app

  • AndroidVideoPlayer在线播放视频

  • AndroidScreenSlide项目切换view动画效果

  • ScrollDownLayout ScrollView和viewpager同事存在的事件处理

  • StarRatingBar星星切换动画

  • AnyShareOfAndroid安卓第三方登录

  • AnimCheckBox按钮点击动画效果

  • android市面主流侧滑框架


更多相关文章

  1. Android网易评论盖楼效果实现
  2. Android 使用TextView实现跑马灯效果
  3. 设置Button背景渐变效果和点击效果
  4. Android项目--团购类客户端
  5. Android 用SlidingDrawer实现抽屉效果

随机推荐

  1. 【Android 内存优化】Bitmap 长图加载 (
  2. android命名大小写问题
  3. Activity启动流程详解
  4. android之命令行创建AVD
  5. Android Flutter 混合开发高仿大厂App
  6. Android中 android:layout_weight 属性
  7. Android studio百度地图SDK开发 2020最新
  8. Android UI设计的基本元素有哪些
  9. android SDK应用
  10. Android创建和使用数据库详…