未來的我,希望能看到這篇文章的時(shí)候,想一想什么都走過來了,還有什么走不得呢,無論何時(shí)何地,不要停下學(xué)習(xí)的腳步。
創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的撫遠(yuǎn)網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!mainactivity篇
package com.example.qingdan;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void click1(View v) {
//【1】創(chuàng)建意圖對(duì)象
Intent intent =new Intent();
//【2】設(shè)置撥打電話的動(dòng)作
intent.setAction(Intent.ACTION_CALL);
//【3】設(shè)置撥打的數(shù)據(jù)
intent.setData(Uri.parse("tel:"+119));
//【4】開啟Activity
startActivity(intent);
}
//隱式意圖
public void click2(View v){
//[1]創(chuàng)建意圖對(duì)象
Intent intent=new Intent();
//[2]設(shè)置跳轉(zhuǎn)的動(dòng)作
intent.setAction("com.iteheima.comm");
//設(shè)置category
intent.addCategory("android.intent.category.DEFAULT");
//設(shè)置數(shù)據(jù)
//intent.setData(Uri.parse("itheima:"+110));
//設(shè)置數(shù)據(jù)類型
//intent.setType("aa/bb");//調(diào)用setdate會(huì)自動(dòng)清除setdata
//所以出現(xiàn)此種情況,我們應(yīng)該調(diào)用如下編程
intent.setDataAndType(Uri.parse("itheima:"+110), "aa/bb");//itheima是data中已經(jīng)配置好了的,所以上述同理只能用‘tel’
//開啟activity
startActivity(intent);
}
//顯示意圖
//點(diǎn)擊按鈕跳轉(zhuǎn)到 TestActivity
public void click3(View v) {
//[1]創(chuàng)建意圖對(duì)象 意圖就是我要完成一件事
Intent intent = new Intent(this,test3activity.class);
//[2]設(shè)置包名和類名 packageName:當(dāng)前應(yīng)用的包名
//intent.setClassName("com.itheima.newactivity", "com.itheima.newactivity.Test3Activity");
//[3]開啟Activity
startActivity(intent);
}
}
test3activity篇
package com.example.qingdan;
import android.os.Bundle;
import android.app.Activity;
public class test3activity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO 自動(dòng)生成的方法存根
super.onCreate(savedInstanceState);
//加載布局
setContentView(R.layout.activity_test);
}
}
testactivity篇
package com.example.qingdan;
import android.app.Activity;
import android.os.Bundle;
public class testactivity extends Activity{
//當(dāng)Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO 自動(dòng)生成的方法存根
super.onCreate(savedInstanceState);
//加載布局
setContentView(R.layout.activity_test);
}
}
layout——activitymain篇
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click1"
android:text="撥打電話"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click2"
android:text="跳轉(zhuǎn)到activity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click3"
android:text="跳轉(zhuǎn)到activity"/>
</LinearLayout>
activitymain——test3篇
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="wo shi test"
/>
</LinearLayout>
activitymain-test篇
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我是testActivity333" />
</LinearLayout>
android manifest篇
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.qingdan"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.qingdan.MainActivity"
android:icon="@drawable/head1"
android:label="我是第二個(gè)頁面" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.qingdan.testactivity"
android:icon="@drawable/head2"
android:label="我是第一個(gè)頁面" >
《!----》主入口》
<intent-filter>
<action android:name="com.iteheima.comm" />
<data android:scheme="itheima"
android:mimeType="aa/bb"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
《!我們可以創(chuàng)建出多個(gè)過濾器,只要,前面name,category能匹配到就行了,有一個(gè)就行哪怕data改變也可以》
<intent-filter>
<action android:name="com.iteheima.comm" />
<data android:scheme="itheima"
android:mimeType="aa/bb"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--配置Activity3 -->
<activity android:name="com.example.qingdan.test3activity"></activity>
</application>
</manifest>
ok,結(jié)束,主要是自己太累了,想休息一會(huì),就這樣吧
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
新聞標(biāo)題:android中顯示意圖和隱式意圖(附帶實(shí)現(xiàn)打電話)-創(chuàng)新互聯(lián)
本文地址:http://bm7419.com/article44/ddppee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、ChatGPT、做網(wǎng)站、網(wǎng)站制作、品牌網(wǎng)站制作、手機(jī)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容