标签:
例子1
定义一个activity的active,category,并调用
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.zzzzzzzzz" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Activity2" android:label="@string/title_activity_activity2" > <intent-filter > <action android:name="aaaaaaaaaaa"/> <action android:name="bbbbbbbbbbbbbb"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="ccc"/> </intent-filter> </activity> </application> </manifest>
调用代码
Button btn=(Button)findViewById(R.id.button1); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(); intent.setAction("aaaaaaaaaaa"); intent.addCategory("ccc"); startActivity(intent); } });
显示第二个窗体代码
TextView v1=(TextView)findViewById(R.id.textView1); TextView v2=(TextView)findViewById(R.id.textView2); v1.setText("active:"+getIntent().getAction()); Set<String> sets=getIntent().getCategories(); v2.setText("category:"+sets+"");
例子2
查看并显示联系人电话
标签:
原文地址:http://www.cnblogs.com/weijj/p/4187673.html