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做的商城客户端,效果很不错

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

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

  • AndroidVideoPlayer在线播放视频

  • AndroidScreenSlide项目切换view动画效果

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

  • StarRatingBar星星切换动画

  • AnyShareOfAndroid安卓第三方登录

  • AnimCheckBox按钮点击动画效果

  • android市面主流侧滑框架


更多相关文章

  1. Android(安卓)使用TextView实现跑马灯效果
  2. Android网易评论盖楼效果实现
  3. Android操作HTTP实现与服务器通信
  4. Android客户端通过socket与服务器通信
  5. 设置Button背景渐变效果和点击效果
  6. Android(安卓)Push Notificatioin Service(Android消息推送)
  7. Android客户端通过socket与服务器通信
  8. Android调用shell脚本并获得输出
  9. Android项目--团购类客户端

随机推荐

  1. Android(安卓)退出多个Activity | 退出程
  2. android画出图片阴影!!!!!!!!!!!!!!
  3. 个人作品
  4. Android面试系列文章2018之Java部分IO编
  5. 安卓开发文件缓存方法的具体实现(参考代
  6. Android(安卓)官网无法访问的解决方法
  7. android的armeabi和armeabi-v7a
  8. Android存储数据的方式
  9. react-native 中配置极光推送 Android关
  10. React Native for Android(安卓)实战(一):配