第49天:Intent的简介

1.操作系统考完了,还有一门就解放了,这周六Xman,好慌。

2.做了一道非常坑爹的android题

攻防世界Mobile的APK逆向-2,坑死人了,好吧,也是我太菜了。

拿到题,安装失败。第一次碰见安装失败的题。

直接上JEB神器吧。

发现这题代码量很大,而且很多函数都不认识,只知道是一个广播。

花了点时间梳理了程序运行流程,根本不知道flag在哪里。。。。直接自闭。

最后只能百度了,才知道AndroidMainifest.xml中有明文?????

然后通过这道题了解一下intent吧。

Intent

主要有4个作用:

  1. startActivity   启动一个Activity,大多用于跳转界面。
  2. startService   启动一个Service,菜鸡如我,还没碰到过
  3. sendBroadcast  发送广播
  4. Intent-Filter   指定组件
7个属性
ComponentName组件名称
Action动作
Category类别
Data数据
TypeMIME类型
Extras额外
Flags标记

显示Intent

直接使用startActivity,指明需要跳转到哪个Activity。

隐式Intent

通过setAction等设置属性来匹配AndroidMainfest中的Intenet-Filter。

//分享功能就是通过隐式Intent完成的。
Intent sendIntent = new Intent();  
sendIntent.setAction(Intent.ACTION_SEND);  
sendIntent.putExtra(Intent.EXTRA_TEXT,"This is my text to send.");  
sendIntent.setType("text/plain");  
startActivity(sendIntent); 
<intent-filter>
       <action android:name="android.intent.action.VIEW"></action>  
       <category android:name="android.intent.category.DEFAULT"></category>
       <category android:name="android.intent.category.BROWSABLE"></category>   
       <data
            android:scheme="app"
            android:host="test">
       </data>  
</intent-filter>
 
<!-- 
android:scheme="app"表示配置接受的协议为app,相当于http://www.baidu.com中的http或者https
android:host="test"表示配置接受的域名为test,相当于http://www.baidu.com中的www.baidu.com
-->

代码来源:https://blog.csdn.net/xia236326/article/details/81837521

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值