主要包括TextInputLayout、SwitchCompat、SnackBar、FloatingActionButton、Shadows、Ripples、TabLayout、RecyclerView、Card、NavigationView、BottomSheet、Palette控件。
Android Material Design 添加依赖 https://blog.csdn.net/yjdsqb/article/details/80140593 //添加依赖 implementation ‘com.android.support:design:28.0.0’
通过android:src修改图片 通过app:backgroundTint修改背景颜色 通过app:fabSize设置大小,只有两个选项normal和mini xmlns:app=“http://schemas.android.com/apk/res-auto” 12.
<android.support.design.widget.NavigationView android:id="@+id/navId" android:layout_width="300dp" android:layout_height="match_parent" android:layout_gravity="right" app:headerLayout="@layout/header_view_layout" app:menu="@menu/menu"> </android.support.design.widget.NavigationView> Menu 布局 <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/action_set" android:title="设置" android:icon="@mipmap/settings"/> <item android:id="@+id/action_about" android:title="关于" android:icon="@mipmap/message_icon"/> <item android:id="@+id/action_clear" android:title="清除" android:icon="@android:drawable/ic_notification_clear_all"/> <item android:id="@+id/action_btn" android:title="测试" android:icon="@mipmap/ic_launcher"/> </menu> //获取NavigationView nv = findViewById(R.id.navId); drawerLayout = findViewById(R.id.rootId); //获取navigation head view; View headerView = nv.getHeaderView(0); //获取headview的imagview littleImg = headerView.findViewById(R.id.littleBoyImg);1,注册,登录成为开发者。 官方网站:https://www.jiguang.cn 2,在控制台创建应用: 参考链接:https://www.jiguang.cn/dev/#/app/list#dev 3,设置包名。包名一定和应用程序包名一致。 4,生成对应的AppKey 5,集成sdk 使用jcenter自动集成 https://docs.jiguang.cn//jpush/client/Android/android_guide/#jcenter 6,定义一个Application类,在oncreate里调用。
JPushInterface.setDebugMode(true);//调试模式。 JPushInterface.init(this);7,在AndroidManifest.xml里, 添加 Application。 8,定义一个receiver例如MyReceiver, 继承 BroadcastReceiver,并重写onReceiver函数。
9,在AndroidManifest中注册MyReceiver。注意包名别忘了写。
<receiver android:name=".MyReceiver" android:enabled="true" android:exported="false"> <intent-filter> <action android:name="cn.jpush.android.intent.REGISTRATION" /> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_CLICK_ACTION" /> <action android:name="cn.jpush.android.intent.CONNECTION" /> <category android:name="com.bawei.jiguang1610" /> </intent-filter> </receiver>10,在MyReceiver里接收信息。 参考链接:https://docs.jiguang.cn//jpush/client/Android/android_api/#receiver
public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction() == JPushInterface.ACTION_MESSAGE_RECEIVED) { Bundle bundle = intent.getExtras(); String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);//读取自定义信息内容 String extras = bundle.getString(JPushInterface.EXTRA_EXTRA); //读取自定义信息附加字段, 是一个json字符串。 String value = null; try { JSONObject jsonObject = new JSONObject(extras); value = (String) jsonObject.get("class"); //读取附件字段class的value值. } catch (JSONException e) { e.printStackTrace(); } Log.d("onReceive:", "ACTION_MESSAGE_RECEIVED::" + message); } else if (intent.getAction() == JPushInterface.ACTION_NOTIFICATION_RECEIVED) { Log.d("onReceive:", "ACTION_NOTIFICATION_RECEIVED"); Bundle bundle = intent.getExtras(); String content = bundle.getString(JPushInterface.EXTRA_ALERT); //读取通知内容 Log.d("onReceive:", "ACTION_MESSAGE_RECEIVED::" + content); String extras = bundle.getString(JPushInterface.EXTRA_EXTRA); //读取自定义信息附加字段, 是一个json字符串。 String value = null; try { JSONObject jsonObject = new JSONObject(extras); value = (String) jsonObject.get("class"); //读取附件字段class的value值. } catch (JSONException e) { e.printStackTrace(); } } } }11,控制台发送自定义信息: 12,控制台发送通知:
