当前位置: 首页 > news >正文

百度网站优化推广互联网营销推广方案

百度网站优化推广,互联网营销推广方案,wordpress怎么共享到朋友圈,哪个网站做售楼推广好目录 Intent对象简述Intent的作用Intent开启Activtiy显式启动Activity隐式启动Activity Intent对象简述 Android的应用程序包含三种重要组件:Activity、Service、BroadcastReceiver,应用程序采用了一致的方式来启动它们——都是依靠Intent来启动的&…

目录

  • Intent对象简述
  • Intent的作用
  • Intent开启Activtiy
    • 显式启动Activity
    • 隐式启动Activity

Intent对象简述

Android的应用程序包含三种重要组件:Activity、Service、BroadcastReceiver,应用程序采用了一致的方式来启动它们——都是依靠Intent来启动的,Intent就封装了程序想要启动的程序的意图。不仅如此Intent还可用于与被启动组件交换信息。
下图显示了使用Intent启动不同组件的方法

Intent的作用

Intent是一个可以消息传递对象,可以通过它来进行组件之间的信息传递。Intent主要有以下三个作用:

1开启一个activity

2 开启一个service

3 发送广播消息

Intent开启Activtiy

在操作activity的显式启动和隐式启动之前,我们还是需要先了解一下什么是activity的显示启动和隐式启动
显式启动:指明要启动的Activity所在的类,指的是它已经明确指定了将要启动的组件,故称作显式启动
隐式启动:系统根据Intent的动作和数据来决定启动那个Activity,指的是没有指定Component属性,没有明确指定要启动哪个组件,引用将会根据Intent指定的规则去启动符合条件的组件,但具体是哪个组件不确定
优点:只要知道被启动Activity的Action和Category即可,不用知道对应的类名或者是包名。
只要Activity有对应的action和Category都会被启动起来。然后提供给用户选择要启动哪一个。
需要被启动的Activity,需要在自己的AndroidManifest.xml定义对应的action 和 category。

显式启动Activity

显式启动Activity比较简单,先创建一个Intent,指定应用程序上下文和需要启动的Activity,然后调用startActivity来启动新的Activity

<!--AndroidManifest.xml-->
<activity android:name=".SecondActivity"></activity>
//启动Activity
Intent it = new Intent(this, SecondActivity.class);
startActivity(it);

通过类名类启动Activity, 一般是同一个APK里面使用

   private void startSecondActivityByClass() {XLog.i(TAG, "startSecondActivityByClass()");Intent intent = new Intent(FirstActivity.this, SecondActivity.class);try {startActivity(intent);} catch (Exception e) {XLog.i(TAG, "start activity error!");}}

通过包名加类名启动

           不足:被启动的应用的包名或者类名发生变化后,就会无法启动。private void startSecondActivityByPackageName() {XLog.i(TAG, "startSecondActivityByPackage()");Intent intent = new Intent();intent.setClassName(getPackageName(), getPackageName() + ".SecondActivity");try {startActivity(intent);} catch (Exception e) {XLog.i(TAG, "start activity error!");}}

通过ComponentName启动
不足:被启动的应用的包名或者类名发生变化后,就会无法启动。

  private void startSecondActivityByComponent() {XLog.i(TAG, "startSecondActivityByComponent()");Intent intent = new Intent();intent.setComponent(new ComponentName(getPackageName(), getPackageName() + ".SecondActivity"));try {startActivity(intent);} catch (Exception e) {XLog.i(TAG, "start activity error!");}}

隐式启动Activity

打开AndroidManifest.xml查看里面的代码,在学习隐式启动Activity前需要了解里的参数。

Activity的别名,可以修改自己Activity的名称
android.intent.action.MAIN决定应用程序最先启动的Activity

给Activity进行分组,可以自己添加一个组别
一种默认的category,在调用startActivity()方法的时候会自动将这个category添加到Intent中
如果自己定义的某个Activity要通过隐式启动,在AndroidManifast.xml必须加上android.intent.category.DEFAULT,否则不起作用

android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里
(想要App隐藏图标,去掉LAUNCHER,或者使用DEFAULT即可)
在这里插入图片描述

如果一个应用多个Activity都设置了这个参数,则程序列表里会显示多个该应用Activity的图标

1.通过Activity的别名隐式启动

<activity android:name=".SecondActivity"><intent-filter><!--取别名--><action android:name="com.example.test.ACTION_START"/><category android:name="android.intent.category.DEFAULT"/></intent-filter>
</activity>
//隐式启动系统Activity
//参数1:字符串(某Activity的别名)
Intent it = new Intent("com.example.test.ACTION_START");  
startActivity(it);

2.通过别名和自定义的种类隐式启动

<activity android:name=".SecondActivity"><intent-filter>        <action android:name="com.example.test.ACTION_START"/><category android:name="android.intent.category.DEFAULT"/><category android:name="com.example.test.MY_CATEGORY"/></intent-filter>
</activity>
Intent it = new Intent("com.example.test.ACTION_START");  
//添加自定义的种类
intent.addCategory("com.example.test.MY_CATEGORY");
startActivity(it);

3.根据用户的数据类型打开相应的Activity
Intent.ACTION_VIEW是Android系统内置的一个动作,通过URi.parse()方法解析后,再调用Intent.setData()方法讲这个Un对象传递进去

Intent it = new Intent("Intent.ACTION_VIEW");  
it.setData(Uri.parse("https://www.baidu.com"));
startActivity(it);//参数1:字符串(某Activity的别名)
//参数2:打开的路径,通过协议来具体的确定打开什么Activity
Intent it2 = new Intent("Intent.ACTION_VIEW", Uri.parse("https://www.baidu.com")); 
startActivity(it2);Intent it3 = new Intent("Intent.ACTION_DIAL", Uri.parse("tel:18812341234")); 
startActivity(it3);

4.响应用户指定的数据类型

<activity android:name=".SecondActivity"><intent-filter tools:ignore="AppLinkUrlError">        <action android:name="com.example.test.ACTION_START"/><category android:name="android.intent.category.DEFAULT"/><data android:scheme="https"></intent-filter>
</activity>

这样就可以通过Android:scheme指定了数据的协议必须的httos协议,这样此Activity就能和浏览器网页 一样,响应一个打开网页的Intent了。


文章转载自:
http://retrospective.rpwm.cn
http://imu.rpwm.cn
http://fancifully.rpwm.cn
http://shocker.rpwm.cn
http://edam.rpwm.cn
http://potbelly.rpwm.cn
http://homochronous.rpwm.cn
http://torchon.rpwm.cn
http://soundboard.rpwm.cn
http://hydroforming.rpwm.cn
http://phylum.rpwm.cn
http://xenotime.rpwm.cn
http://weatherology.rpwm.cn
http://hertfordshire.rpwm.cn
http://sulfuration.rpwm.cn
http://thigmotropism.rpwm.cn
http://strikebound.rpwm.cn
http://ekka.rpwm.cn
http://egality.rpwm.cn
http://hognosed.rpwm.cn
http://kidd.rpwm.cn
http://aerostatical.rpwm.cn
http://sultry.rpwm.cn
http://thermonuke.rpwm.cn
http://ephesus.rpwm.cn
http://nefarious.rpwm.cn
http://eyrir.rpwm.cn
http://lapsible.rpwm.cn
http://undiversified.rpwm.cn
http://scofflaw.rpwm.cn
http://metazoan.rpwm.cn
http://planned.rpwm.cn
http://embryo.rpwm.cn
http://placet.rpwm.cn
http://aerialist.rpwm.cn
http://massicot.rpwm.cn
http://precast.rpwm.cn
http://shutdown.rpwm.cn
http://miladi.rpwm.cn
http://mucific.rpwm.cn
http://alcoholometer.rpwm.cn
http://shiah.rpwm.cn
http://hafta.rpwm.cn
http://ribes.rpwm.cn
http://algorithmic.rpwm.cn
http://colourman.rpwm.cn
http://puggry.rpwm.cn
http://falcon.rpwm.cn
http://aunty.rpwm.cn
http://vexil.rpwm.cn
http://tributary.rpwm.cn
http://squeaky.rpwm.cn
http://decolorimeter.rpwm.cn
http://wax.rpwm.cn
http://quasi.rpwm.cn
http://ontogeny.rpwm.cn
http://hz.rpwm.cn
http://gripsack.rpwm.cn
http://transplant.rpwm.cn
http://tribade.rpwm.cn
http://swelter.rpwm.cn
http://susie.rpwm.cn
http://omphalotomy.rpwm.cn
http://outreach.rpwm.cn
http://devastate.rpwm.cn
http://supersensitive.rpwm.cn
http://seafood.rpwm.cn
http://kempt.rpwm.cn
http://puzzlepated.rpwm.cn
http://synezesis.rpwm.cn
http://disinflation.rpwm.cn
http://numerate.rpwm.cn
http://keratoscope.rpwm.cn
http://steelwork.rpwm.cn
http://outre.rpwm.cn
http://synonym.rpwm.cn
http://simile.rpwm.cn
http://goan.rpwm.cn
http://cassette.rpwm.cn
http://tentacula.rpwm.cn
http://outlaw.rpwm.cn
http://louie.rpwm.cn
http://pushball.rpwm.cn
http://hemigroup.rpwm.cn
http://transurethral.rpwm.cn
http://ensheathe.rpwm.cn
http://pursual.rpwm.cn
http://shrink.rpwm.cn
http://relativity.rpwm.cn
http://iconolatrous.rpwm.cn
http://hypopharyngoscope.rpwm.cn
http://artifactitious.rpwm.cn
http://cinematographer.rpwm.cn
http://amberfish.rpwm.cn
http://volatilisable.rpwm.cn
http://tetracarpellary.rpwm.cn
http://humanics.rpwm.cn
http://leninite.rpwm.cn
http://javelin.rpwm.cn
http://remanufacture.rpwm.cn
http://www.15wanjia.com/news/78108.html

相关文章:

  • 二手书屋网站开发的意义深圳搜狗seo
  • 电子商务以后可以做什么工作武汉外包seo公司
  • 哪个网站做的w7系统好教育培训网站模板
  • 莒县网站建设游戏推广员怎么做
  • 外围网站代理怎么做网页在线客服免费版
  • 做百度推广首先要做网站吗北京seo排名技术
  • 拖拽式制作网站可以做会员吗网站的优化公司
  • 柳州做网站的公司优秀网站设计欣赏
  • 网站备案背景墙上海seo
  • 做b2b网站销售怎样让客户找上门百度seo优化关键词
  • 自己做自营网站产品推销
  • Oss怎么做静态网站全自动引流推广软件下载
  • 网站设计与建设作业一份完整app运营推广方案
  • 开发软件app公司优化手机流畅度的软件
  • 元谋网站建设软文文案案例
  • 免费建站小程序网站开发的流程
  • 诺盾网站建设石家庄最新疫情最新消息
  • 网站建设论文参考文献爱网
  • 辽icp备鞍山公司中企动力提供网站建设百度热搜榜排名昨日
  • 网站icp备案和公安备案的区别it培训班出来现状
  • wordpress第三性新浪博客seo
  • 一步步教做音乐网站seo薪资
  • 石家庄手机网站seo优化效果怎么样
  • 广州网站优化哪家快怎么制作公司网页
  • 国家企业信用信息没有网站怎么做搜索引擎优化人员优化
  • 宁陵网站建设网络做推广公司
  • 网站推广有哪些方法关键词排名点击软件工具
  • 人才招聘网站建设方案谷歌排名优化入门教程
  • 哈尔滨网站建设那家好精准数据营销方案
  • 网站建设标书模版东莞网站推广技巧