尾声
开发是需要一定的基础的,我是08年开始进入Android这行的,在这期间经历了Android的鼎盛时期,和所谓的Android”凉了“。中间当然也有着,不可说的心酸,看着身边朋友,同事一个个转前端,换行业,其实当时我的心也有过犹豫,但是我还是坚持下来了,这次的疫情就是一个好的机会,大浪淘沙,优胜劣汰。再等等,说不定下一个黄金浪潮就被你等到了。
- 330页 PDF Android核心笔记
- 几十套阿里 、字节跳动、腾讯、华为、美团等公司2020年的面试题
- PDF和思维脑图,包含知识脉络 + 诸多细节
- Android进阶系统学习视频
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
private NotificationReceiver notificationReceiver;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCollector.addActivity(this);
}
@Override
protected void onResume() {
super.onResume();
IntentFilter intentFilter_notice = new IntentFilter();
intentFilter_notice.addAction(“com.example.broadcastbestpractice.NOTICE_TEST”);
notificationReceiver = new NotificationReceiver();
registerReceiver(notificationReceiver, intentFilter_notice);
}
@Override
protected void onPause() {
super.onPause();
if(notificationReceiver != null){
unregisterReceiver(notificationReceiver);
notificationReceiver = null;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
ActivityCollector.removeActivity(this);
}
class NotificationReceiver extends BroadcastReceiver{
@Override
public void onReceive(final Context context, Intent intent) {
//获取通知管理实例
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//8.0一张版本判断
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
NotificationChannel channel=new NotificationChannel(“important”,“Important”,NotificationManager.IMPORTANCE_HIGH);
assert manager != null;
manager.createNotificationChannel(channel);
}
//通知点击事项
Intent intent1=new Intent(context,NotificationActivity.class);
PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intent1,0);
Notification notification= new NotificationCompat.Builder(context,“important”)
.setContentTitle(“收到一条通知”)
.setContentText(“你好”)
.setSmallIcon(R.mipmap.ic_launcher)//通知图标
.setContentIntent(pendingIntent)//点击跳到通知详情
.setAutoCancel(true)//当点击通知后显示栏的通知不再显示
.build();
assert manager != null;
manager.notify(1,notification);
}
}
}
3.MainActivity.java
public class MainActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button send_notice=findViewById(R.id.send_notice);
send_notice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(“com.example.broadcastbestpractice.NOTICE_TEST”);
sendBroadcast(intent);
}
});
}
}
4.activity_main.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“com.example.broadcastbestpractice.MainActivity”>
<Button
android:layout_centerInParent=“true”
android:id=“@+id/send_notice”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_marginLeft=“20dp”
android:layout_marginRight=“20dp”
android:text=“发送通知”/>
推荐学习资料
-
Android进阶学习全套手册
-
Android对标阿里P7学习视频
-
BAT TMD大厂Android高频面试题
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-CTypAgsl-1715757544311)]
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!