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

网站发布后打不开公司网站备案名称

网站发布后打不开,公司网站备案名称,聊城专业网站开发公司,wordpress登录js深入理解Intent和IntentFiler(二)转载请表明出处#xff1a;http://blog.csdn.net/u012637501(嵌入式_小J的天空) 在上一篇文章中#xff0c;我们比較具体学习了Intent的相关知识#xff0c;如今将学习怎样设置Intent对象的这些属性以及怎样使用他们来启动组件。… 深入理解Intent和IntentFiler(二) 转载请表明出处http://blog.csdn.net/u012637501(嵌入式_小J的天空)     在上一篇文章中我们比較具体学习了Intent的相关知识如今将学习怎样设置Intent对象的这些属性以及怎样使用他们来启动组件。Intent对象是一组信息我们能够通过设置其Action、Data、Category属性来指定启动哪个组件并完毕什么样的动作(包括动作所需的数据)。     意图分为显示intent和隐式intent。所谓显示intent,指的是Intent已经明白了它将要启动哪个组件-通过指定Intent对象的Component属性实现。而隐式intent指的是Intent不能确定它将要启动哪个组件(没有指定Component属性)-通过AndroidManifest.xml文件里的Intent Filter来对组件进行筛选来确定启动的组件。 一、显式intent     显式意图。顾名思义就是指Intent已经明白以我们可了它将要启动哪个组件。因为一个组件类能够通过其所在的包名和类名唯一的确定所以通过intent的Component属性来实现。Intent的Component属性须要接受一个ComponentName对象。其构造函数传入了该组件的包名、类名。 1.显式intent开发基本思路 (1)创建一个ComponentName对象用于为意图指定组件包名、类名 ComponentName compnew ComponentName(ComponentAttr.this,SecondaryActivity.class); (2)创建一个Intent对象并为该对象设置Component属性 Intent intentnew Intent(); intent.setComponent(comp); 注意通过使用Intent不同的构造函数(1)、(2)步骤能够合并为     Intent intentnew Intent(ComponentAttr.this,SecondaryActivity.class); (3)启动一个类名为SecondaryActivity的Activity组件 startActivity(intent); 或者 startActivityForResult(intent,requestCode); //关闭启动的Activity会返回结果 (4)实现被启动的组件SecondaryActivity类(继承于Activity) (5)在AndroidManifest.xml加入一个Activity/Activity元素可是无需配置intent-filter元素 !-- 被intent启动的activity --activityandroid:name.SecondaryActivityandroid:label第二个Activity界面 intent-filteraction android:nameaction.CRAZYIT_ACTION/category android:nameandroid.intent.category.DEFAULT //intent-filter/activity 博主笔记1除了上述Intent的setComponent方法我们还能够利用setClass来指定须要启动的详细组件 Intent intentnew Intent(); intent.setClass(ComponentAttr.this,SecondaryActivity.class); startActivity(intent); 二、隐式intent     隐式intent顾名思义就是没有指明intent究竟要启动哪个组件。显式intent能够通过设置其Component属性实现。而隐式intent就通过Intent Filter来实现。详细的说就是我们事先设置好意图启动组件的相关信息(intent属性)然后再在其它组件的AndroidManifest.xml文件设置好对应的intent属性。当组件发出意图时。Android系统通过查找project文件AndroidManifest.xml(或者系统级组件)其它组件的intent-filter/相关信息来进行匹配。筛选得到满足意图条件的组件。 1.使用Action属性开发基本思路        Intent是组件之间的通信的载体组件的通信能够分为应用内部组件之间的通信和应用间的通信。Intent的Action、Category属性都是一个普通的字符串当中Action代表Intent索要完毕的一个抽象动作Category属性用于为Action添加附加的类别信息。 (1)应用内部组件通信-自己定义字符串 方式 public final String CUSTOME_ACTIONintent.action.CUSTOME_JIANG;//字符串能够随意 Intent intentnew Intent(); //创建一个Intent对象 intent.setAction(ActionAttr.CUSTOME_ACTION); //注意ActionAttr为我们创建的类 startActivity(intent); //启动一个Activity (2)与其它应用程序通信-使用系统预定action常量 Intent intentnew Intent(); intent.setAction(Intent.ACTION_CALL); //当中ACTION_CALL为Intent类的静态成员变量能够类直接调用 startActivity(intent); 2.使用Action、Category属性开发基本思路 (1)应用内部组件通信-自己定义字符串 方式 public final String CUSTOME_ACTIONintent.action.CUSTOME_JIANG;//字符串能够随意 public final String CUSTOME_CATEGORYintent.action.CUSTOME_CATEGORY;//字符串能够随意 Intent intentnew Intent(); //创建一个Intent对象 intent.setAction(ActionAttr.CUSTOME_ACTION); //注意ActionAttr为我们创建的类 intent.addCategory(ActionAttr.CUSTOME_CATEGORY); startActivity(intent); //启动一个Activity (2)使用系统预定action、category常量-下面代码实现当点击某个button时通过Intent对象实现返回HOME桌面。 Intent intentnew Intent(); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME);//返回Home桌面 startActivity(intent); //启动一个Activity 注意这里无需设置AndroidManifest.xml 假设是实现应用内部组件的通信。除了上述(1)(2)步骤我们还须要完毕步 (3)实现须要启动的Activity,如SecondaryActivity.java,ThirdActivity.java使其继承于Activity; (4)在projectAndroidManifest.xml加入activity/activity元素并加入intent-filter/相关信息 activity android:name.SecondaryActivity android:label第二个Activity界面 intent-filter action android:nameintent.action.JIANG_ACTION / category android:nameintent.action.JIANG_CATEGORY / category android:nameandroid.intent.category.DEFAULT / /intent-filter /activity activity android:name.ThirdActivity android:label第三个Activity界面 intent-filter action android:nameintent.action.JIANG_ACTION / category android:nameintent.action.JIANG_CATEGORY / category android:nameandroid.intent.category.DEFAULT / /intent-filter /activity 博主笔记2实际上。我们在开发包括意图的应用程序中Action属性和Category属性是配合使用的。由于Android系统会给主动Activity在AndroidManifest.xml中默认一个Action属性和Category属性。即  intent-filter                 action android:nameandroid.intent.action.MAIN /                        //应用程序入口                 category android:nameandroid.intent.category.LAUNCHER /   /intent-filter 另外还须要注意几点 1.Action常量等属性。如ACTION_CALL是在设置intent时使用其相应的字符串android.intent.action.CALL在AndroidManifest.xml中使用; 2.当使用Action属性等的系统提前定义常量与其它应用通信时仅仅须要在本应用的AndroidManifest.xml加入对应的权限就可以。 3.一个Activity中仅仅能且必须定义一个Action属性和一个Category属性当中。Category属性系统会分配其默认常量CATEGORY_DEFAULT 3.源码     该实例主要完毕2个功能 (1)实现一个button。使用Action属性和Category属性启动一个Activity; (2)实现一个button用于返回HOME界面 (1).FirstActivity.java主Activity package com.example.android_intent_2; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class ActionCateAttr extends Activity {//自己定义一个action常量org.crazyit.public final static String CRAZYIT_ACTIONintent.action.JIANG_ACTION;public final static String CRAZYIT_CATEGORYintent.action.JIANG_CATEGORY;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.first);Button btn(Button)findViewById(R.id.button);btn.setOnClickListener(new OnClickListener(){Overridepublic void onClick(View v) {//创建一个Intent对象Intent intentnew Intent();intent.setAction(ActionCateAttr.CRAZYIT_ACTION); //设置action属性intent.addCategory(ActionCateAttr.CRAZYIT_CATEGORY); //设置category属性startActivity(intent);}});//为btn注冊一个事件监听器对象/*返回桌面按钮*/Button btn1(Button)findViewById(R.id.home);btn1.setOnClickListener(new OnClickListener(){Overridepublic void onClick(View v) {//创建一个Intent对象Intent intentnew Intent();intent.setAction(Intent.ACTION_MAIN); //设置action属性intent.addCategory(Intent.CATEGORY_HOME);//设置category属性startActivity(intent);}});//为btn注冊一个事件监听器对象} } (2).AndroidManifest.xml ?xml version1.0 encodingutf-8? manifest xmlns:androidhttp://schemas.android.com/apk/res/androidpackagecom.example.android_intent_2android:versionCode1android:versionName1.0 uses-sdkandroid:minSdkVersion11android:targetSdkVersion14 /applicationandroid:allowBackuptrueandroid:icondrawable/ic_launcherandroid:labelstring/app_nameandroid:themestyle/AppTheme activityandroid:name.ActionCateAttrandroid:label第一个Activity界面 intent-filteraction android:nameandroid.intent.action.MAIN /category android:nameandroid.intent.category.LAUNCHER //intent-filter/activityactivityandroid:name.SecondaryActivityandroid:label第二个Activity界面 intent-filteraction android:nameintent.action.JIANG_ACTION /category android:nameintent.action.JIANG_CATEGORY /category android:nameandroid.intent.category.DEFAULT //intent-filter/activityactivityandroid:name.ThirdActivityandroid:label第三个Activity界面 intent-filteraction android:nameintent.action.JIANG_ACTION /category android:nameintent.action.JIANG_CATEGORY /category android:nameandroid.intent.category.DEFAULT //intent-filter/activity/application /manifest (3)在project中加入SecondaryActivity.java,ThirdActivity.java继承于Activity. (4)效果 3.使用Data、Type属性开发基本思路     Action属性为Intent对象描写叙述了一个动作。那么Data属性就为Intent对象的Action属性提供了操作的数据。Type属性用于指定该Data所指定Uri相应的MIME类型这样的类型能够是不论什么自己定义的MIME类型仅仅要符合abc/xyz格式的字符串就可以。这里须要注意的是Type属性和Data属性通常会出现相互覆盖的情况假设希望Intent既有Data属性也有Type属性必须通过setDataAndType()方法来实现。这里须要注意的是Data属性仅仅接受一个Uri对象。一个Uri对象通常通过例如以下形式的字符串来表示     Uri字符串格式scheme://host:port/path 举例 content://com.android.contacts/contacts/1或tel://18819463209     这里有两种情况。一是启动系统级应用程序;二是。启动应用内部组件。前者无需配置AndroidManifest.xml中的data../元素。仅仅需加入对应权限就可以后者。须要配置AndroidManifest.xml中的data/元素内容。当中。为组件声明Data、Type属性都通过data../元素格式例如以下     data android:mimeType        //用于声明该组件所能匹配的Intent的Type属性             android:scheme             //协议              android:host                 //用于声明该组件所能匹配的Intent的Data属性host部分(主机)              android:port                 //串口              android:path                //资源路径             android:pathPrefix        //Data属性的前缀             android:pathPattern/    //Data属性的path字符串模板 情况一、启动系统级应用组件 (1)实现一个Intent对象。并启动组件 Intent intentnew Intent(); //创建一个Intent对象 String datacontent://com.android.contacts/contacts/1; Uri uriUri.parse(data); //将字符串转换为Uri intent.setAction(Intent.ACTION_VIEW); //设置Intent对象Action属性 intent.setData(uri); //设置Intent对象Data属性 startActivity(intent); 或者 Intent intentnew Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(content://com.android.contacts/contacts/1)); startActivity(intent); (2)在AndroidManifest.xml中加入对应的权限 在Android中读取电话信息时要注意增加 use-permission android:nameandroid.permission.READ_CONTACTS/ 在android中使用BroadcastReceiver时 use-permission android:nameandroid.permission.RECEIVE_SMS/ 在android中使用有关的文件下载功能时要使用到的 use-permission android:nameandroid.permission.INTERNET/ use-permission android:nameandroid.permission.WRITE_EXTERNAL_STORAGE/ (3)源码     该应用程序实现三个button实现三个功能打开网页、编辑联系人、拨打电话 firstActivity.java package com.android.android_intent_4; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.content.Intent; import android.net.Uri; import android.os.Bundle; public class MainActivity extends ActionBarActivity { Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /*第一个按键功能打开网页*/ Button btn1(Button)findViewById(R.id.button1); btn1.setOnClickListener(new OnClickListener(){ //为按钮1注冊一个事件监听器对象 Override public void onClick(View v) { //1.创建Intent Intent intentnew Intent(); //2.设置action、data属性 String datahttp://www.baidu.com; Uri uriUri.parse(data); //将字符串转化为Uri-通用资源标识 intent.setAction(Intent.ACTION_VIEW); //设置intent属性为系统提前定义的Intent.ACTION_VIEW intent.setData(uri); //为intent设置数据属性。用于传递数据 //3.启动Activity startActivity(intent); }}); /*第二个按键功能编辑标识为1的联系人*/ Button btn2(Button)findViewById(R.id.button2); btn2.setOnClickListener(new OnClickListener(){ //为按钮1注冊一个事件监听器对象 Override public void onClick(View v) { //1.创建Intent Intent intentnew Intent(); //2.设置action、data属性 intent.setAction(Intent.ACTION_EDIT); //设置intent属性为系统提前定义的Intent.ACTION_VIEW intent.setData(Uri.parse(content://com.android.contacts/contacts/1)); //为intent设置数据属性。依据指定的字符解析出Uri对象 //3.启动Activity startActivity(intent); }}); /*第三个按键功能拨打电话18819465188*/ Button btn3(Button)findViewById(R.id.button3); btn3.setOnClickListener(new OnClickListener(){ //为按钮1注冊一个事件监听器对象 Override public void onClick(View v) { //1.创建Intent Intent intentnew Intent(); //2.设置action、data属性 intent.setAction(Intent.ACTION_DIAL); //设置intent属性为系统提前定义的Intent.ACTION_VIEW intent.setData(Uri.parse(tel:18819465188)); //依据指定的字符解析出Uri对象 //3.启动Activity startActivity(intent); }}); } } 效果例如以下图 情况二、启动应用内部组件 (1)实现一个Intent对象并启动组件 Intent intentnew Intent(); //创建一个Intent对象 String datalee://www.fkjava.org:8888/mypath; Uri uriUri.parse(data); //将字符串转换为Uri intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); //设置Intent对象Data属性 startActivity(intent); 或者 Intent intentnew Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(lee://www.fkjava.org:8888/mypath)); startActivity(intent); (2)在AndroidManifest.xml中设置data../元素中的相关内容就可以 data android:mimeTypeandroid:hostandroid:portandroid:pathandroid:pathPrefixandroid:pathPattern/ (3)实现其他Activity 版权声明本文博主原创文章。博客未经同意不得转载。
http://www.zqtcl.cn/news/577793/

相关文章:

  • 企慕网站建设网络推广合肥市网站制作
  • 做空比特币网站大气简约企业网站模板免费下载
  • 坪山网站建设行业现状做网站能月入10万
  • 个人网站有什么内容广西网站建设推广
  • 安徽教育云网站建设网站seo诊断的主要内容
  • 网站建设例子开发工具宏怎么使用
  • 新乡做网站公司哪个地区网站建设好
  • 网站模板怎么编辑网站定制化
  • 利于优化的网站网络科技公司怎么赚钱
  • 制作网站的步骤和方法做物流的网站有哪些功能
  • vs做网站图片明明在文件夹里却找不到中国建筑网官网找客户信息
  • WordPress仿站培训黑龙江新闻夜航
  • 如何利用开源代码做网站济南做网站互联网公司有哪些
  • 生意网app下载官网郑州做网站优化公
  • wordpress网站更换域名wordpress 小工具定制
  • 上海做机床的公司网站设计网站怎样做色卡
  • 一个网站怎么绑定很多个域名做网站后台应该谁来做
  • 跑纸活做网站加大门户网站安全制度建设
  • 多商户开源商城seo对网店的作用有哪些
  • 提供微信网站建设福州seo建站
  • 泉州市住房与城乡建设网站潍坊网站建设方案外包
  • 网络文化经营许可证怎么申请免费seo提交工具
  • 网站建设 需求分析报告手机网站微信网站开发
  • 做司法考试题目的网站建站中企动力
  • 做360网站优化ppt模板免费下载千图网
  • 网站域名哪些后缀更好项目推广平台有哪些
  • 做游戏特效的网站网站开发中安全性的防范
  • 阿里云网站建设好用吗齐诺网站建设
  • 中小企业网站建设行情嘉兴公司的网站设计
  • 做服装有哪些好的网站台州网站建设多少钱