日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android之隐式intent调用

發(fā)布時間:2023/12/10 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android之隐式intent调用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

直接上代碼

MainActivity.java

1 package com.example.test1; 2 3 import android.app.Activity; 4 import android.content.Intent; 5 import android.net.Uri; 6 import android.os.Bundle; 7 import android.view.View; 8 import android.view.View.OnClickListener; 9 import android.widget.Button; 10 11 public class MainActivity extends Activity { 12 13 @Override 14 protected void onCreate(Bundle savedInstanceState) { 15 super.onCreate(savedInstanceState); 16 setContentView(R.layout.activity_main); 17 18 Button btnButton = (Button) findViewById(R.id.button1); 19 20 btnButton.setOnClickListener(new OnClickListener() { 21 22 @Override 23 public void onClick(View v) { 24 // TODO Auto-generated method stub 25 Intent intent = new Intent(); 26 intent.setAction("aa.bb.cc.dd.ee.ff"); 27 28 startActivity(intent); 29 } 30 }); 31 } 32 }

SecondActivity.java

1 package com.example.test1; 2 3 import android.app.Activity; 4 import android.content.Intent; 5 import android.os.Bundle; 6 import android.widget.TextView; 7 8 public class SecondActivity extends Activity { 9 10 @Override 11 protected void onCreate(Bundle savedInstanceState) { 12 13 super.onCreate(savedInstanceState); 14 15 setContentView(R.layout.second_main); 16 17 Intent intent = getIntent(); 18 19 TextView textView = (TextView) findViewById(R.id.textView1); 20 textView.setText(intent.getAction()); 21 } 22 }

activity_main.xml

1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:paddingBottom="@dimen/activity_vertical_margin" 6 android:paddingLeft="@dimen/activity_horizontal_margin" 7 android:paddingRight="@dimen/activity_horizontal_margin" 8 android:paddingTop="@dimen/activity_vertical_margin" 9 tools:context=".MainActivity" > 10 11 <Button 12 android:id="@+id/button1" 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content" 15 android:layout_alignParentTop="true" 16 android:layout_centerHorizontal="true" 17 android:layout_marginTop="124dp" 18 android:text="跳轉(zhuǎn)" /> 19 20 </RelativeLayout>

second_main.xml

1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 > 6 7 <TextView 8 android:id="@+id/textView1" 9 android:layout_width="wrap_content" 10 android:layout_height="wrap_content" 11 android:layout_alignParentLeft="true" 12 android:layout_alignParentTop="true" 13 android:layout_marginLeft="93dp" 14 android:layout_marginTop="176dp" 15 android:text="Large Text" 16 android:textAppearance="?android:attr/textAppearanceLarge" /> 17 18 </RelativeLayout>

很重要的AndroidManifest.xml

1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.example.test1" 4 android:versionCode="1" 5 android:versionName="1.0" > 6 7 <uses-sdk 8 android:minSdkVersion="8" 9 android:targetSdkVersion="17" /> 10 11 <application 12 android:allowBackup="true" 13 android:icon="@drawable/ic_launcher" 14 android:label="@string/app_name" 15 android:theme="@style/AppTheme" > 16 <activity 17 android:name="com.example.test1.MainActivity" 18 android:label="@string/app_name" > 19 <intent-filter> 20 <action android:name="android.intent.action.MAIN" /> 21 22 <category android:name="android.intent.category.LAUNCHER" /> 23 </intent-filter> 24 </activity> 25 <activity android:name="com.example.test1.SecondActivity"> 26 <intent-filter> 27 <action android:name="aa.bb.cc.dd.ee.ff"/> 28 29 <category android:name="android.intent.category.DEFAULT" />//隱式intent調(diào)用,這句必須加 30 </intent-filter> 31 </activity> 32 33 </application> 34 35 </manifest>

?

轉(zhuǎn)載于:https://www.cnblogs.com/ziyouchutuwenwu/archive/2013/05/24/3097153.html

總結(jié)

以上是生活随笔為你收集整理的android之隐式intent调用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。