请问怎么实现Android触屏实现页面跳转触发事件

Android 几种屏幕间跳转的跳转Intent Bundle
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了Android 几种屏幕间跳转的跳转Intent Bundle,有需要的朋友可以参考一下
屏幕使用一个活动来实现,屏幕间是相互独立的,屏幕之间的跳转关系通过Intent来实现。
屏幕间跳转分为以下几类:
1. 屏幕1直接跳转到屏幕2
&&&&& Intent intent = new Intent();
&&&&& intent.setClass(屏幕1活动名.this,屏幕2活动名.class);
&&&&& startActivity(intent);
&&&&& finish();&& //结束当前活动
2. 屏幕1带参数跳转到屏幕2
&& 使用Bundle来传参数。
&& 例子:猜拳游戏
重要代码:
电脑的选择是随机的,本次联系的基本思路是,三个选项利用三个数字来代替,让电脑&& 随机生成一个数字,根据数字的不同来产生不同的结果。
代码如下:public void onClick(View v) {
&&&&&&&&&&&&&&& switch (radioGroup.getCheckedRadioButtonId()){
&&&&&&&&&&&&&&& case R.id.stone:
&&&&&&&&&&&&&&&&&&& player = 0;
&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&& case R.id.scissors:
&&&&&&&&&&&&&&&&&&& player = 1;
&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&& case R.id.textile:
&&&&&&&&&&&&&&&&&&& player = 2;
&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&& default:
&&&&&&&&&&&&&&&&&&& Toast.makeText(MainActivity.this, "请选择", Toast.LENGTH_LONG).show();
&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& skip();
&&&&&&&&&&& }
&&& //页面跳转
&&& private void skip(){
&&&&&&& Intent intent = new Intent();
&&&&&&& intent.setClass(MainActivity.this, ResultMainActivity.class);
&&&&&&& Bundle bundle = new Bundle();
&&&&&&& bundle.putInt("player", player);
&&&&&&& bundle.putInt("computer", new Random().nextInt(3));
&&&&&&& intent.putExtra("result", bundle);
&&&&&&& startActivity(intent);
跳转之后,要接受参数:
代码如下:&& Bundle bundle = this.getIntent().getBundleExtra("result");
&& int playerInt = bundle.getInt("player");
&& int computerInt = bundle.getInt("computer");
猜拳游戏完整代码:
activity_first.xml代码&
代码如下:&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" &
&&& &TextView&&&&&&& android:id="@+id/textView1"&&&&&&& android:layout_width="wrap_content"&&&&&&& android:layout_height="wrap_content"&&&&&&& android:text="请选择您要出的拳:"&&&&&&& android:textSize="20dip" /&&&&
&&& &RadioGroup&&&&&&& android:id="@+id/quans"&&&&&&& android:layout_width="wrap_content"&&&&&&& android:layout_height="wrap_content"&&&&&&& android:orientation="horizontal"&
&&&&&&& &RadioButton&&&&&&&&&&& android:id="@+id/shitou"&&&&&&&&&&& android:layout_width="wrap_content"&&&&&&&&&&& android:layout_height="wrap_content"&&&&&&&&&&& android:checked="true"&&&&&&&&&&& android:text="石头"&&&&&&&&&&& android:textSize="20dip" /&
&&&&&&& &RadioButton&&&&&&&&&&& android:id="@+id/jiandao"&&&&&&&&&&& android:layout_width="wrap_content"&&&&&&&&&&& android:layout_height="wrap_content"&&&&&&&&&&& android:textSize="20dip"&&&&&&&&&&& android:text="剪刀" /&
&&&&&&& &RadioButton&&&&&&&&&&& android:id="@+id/bu"&&&&&&&&&&& android:layout_width="wrap_content"&&&&&&&&&&& android:layout_height="wrap_content"&&&&&&&&&&& android:textSize="20dip"&&&&&&&&&&& android:text="布" /&&&& &/RadioGroup&
&&& &Button&&&&&&& android:id="@+id/chuquan"&&&&&&& android:layout_width="match_parent"&&&&&&& android:layout_height="wrap_content"&&&&&&& android:textSize="20dip"&&&&&&& android:text="出拳" /&
&/LinearLayout&
activity_second.xml代码 代码如下:&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" &
&&& &TextView&&&&&&& android:id ="@+id/show"&&&&&&& android:layout_width="match_parent"&&&&&&& android:layout_height="wrap_content"&&&&&&& android:textSize="20dip"&&&&&&& android:text="@string/hello_world" /&
&/LinearLayout&
firstActivity.java代码
代码如下:package com.example.
import java.util.R
import android.os.Bimport android.app.Aimport android.content.Iimport android.view.Vimport android.view.View.OnClickLimport android.widget.Bimport android.widget.RadioGimport android.widget.Timport android.support.v4.app.NavU
public class firstActivity extends Activity {
&private B&private RadioG&&&& @Override&&& public void onCreate(Bundle savedInstanceState) {&&&&&&& super.onCreate(savedInstanceState);&&&&&&& setContentView(R.layout.activity_first);&&&&&&& setTitle("猜拳游戏");&&&&&&& chuquan = (Button)findViewById(R.id.chuquan);&&&&&&& chuquan.setOnClickListener(mChuQuanListener);&&&&&&& quans = (RadioGroup)findViewById(R.id.quans);&&& }&&& private OnClickListener mChuQuanListener = new OnClickListener()&&& {
&&@Override&&public void onClick(View arg0) {&&&// TODO Auto-generated method stub&&&switch(quans.getCheckedRadioButtonId())&&&{&&&&&& case R.id.shitou:&&&&&& &player = 0;&&&&&& &&&&&&& case R.id.jiandao:&&&&&& &player = 1;&&&&&& &&&&&&& case R.id.bu:&&&&&& &player = 2;&&&&&& &&&&&&& default:&&&&&&&&&&&&&&&&&&& Toast.makeText(firstActivity.this, "请选择", Toast.LENGTH_LONG).show();&&&&&&&&&&&&&&&&&&&&&&}&&&//将的到的值传给secondActivity&&&skip();&&}&&& };&&& private void skip()&&& {&&& &Intent intent = new Intent();&&& &intent.setClass(firstActivity.this, secondActivity.class);&&& &Bundle bundle = new Bundle();&&& &bundle.putInt("player", player);&&& &bundle.putInt("computer", new Random().nextInt(3));&&& &intent.putExtra("result", bundle);&&& &startActivity(intent);&&& }}
secondActivity.java代码&
代码如下:package com.example.
import android.os.Bimport android.app.Aimport android.view.Mimport android.view.MenuIimport android.widget.TextVimport android.widget.Timport android.support.v4.app.NavU
public class secondActivity extends Activity {&&& private TextV&&& @Override&&& public void onCreate(Bundle savedInstanceState) {&&&&&&& super.onCreate(savedInstanceState);&&&&&&& setContentView(R.layout.activity_second);&&&&&&& setTitle("结果");&&&&&&& tv = (TextView)findViewById(R.id.show);&&&&&&& Bundle bundle = this.getIntent().getBundleExtra("result");&&&&&&& int playerInt = bundle.getInt("player");&&&&&&& int computerInt = bundle.getInt("computer");&&&&&&& tv.setText("猜拳结果\n");&&&&&&& tv.append("您的选择:");&&&&&&& intChangeString(playerInt);&&&&&&& tv.append("电脑的选择:");&&&&&&& intChangeString(computerInt);&&&&&&& tv.append("结果:");& &&&&&&& if(playerInt == 0)&&&&&&& {&&&&&&& &if(computerInt == 0)&&&&&&& &{&&&&&&& &&tv.append("平局");&&&&&&& &}&&&&&&& &else if(computerInt == 1)&&&&&&& &{&&&&&&& &&tv.append("您是赢家");&&&&&&& &}&&&&&&& &else&&&&&&& &{&&&&&&& &&tv.append("电脑是赢家");&&&&&&& &}&&&&&&& }&&&&&&& else if(playerInt == 1) &&&&&&& {&&&&&&& &if(computerInt == 0)&&&&&&& &{&&&&&&& &&tv.append("电脑是赢家");&&&&&&& &}&&&&&&& &else if(computerInt == 1)&&&&&&& &{&&&&&&& &&tv.append("平局");&&&&&&& &}&&&&&&& &else&&&&&&& &{&&&&&&& &&tv.append("您是赢家");&&&&&&& &}&&&&&&& }&&&&&&& else&&&& &&&&&&& {&&&&&&& &if(computerInt == 0)& &&&&&&& &{&&&&&&& &&tv.append("您是赢家");&&&&&&& &}&&&&&&& &else if(computerInt == 1)&&&&&&& &{&&&&&&& &&tv.append("电脑是赢家");&&&&&&& &}&&&&&&& &else&&&&&&& &{&&&&&&& &&tv.append("平局");&&&&&&& &}&&&&&&& }&&& }&&& private void intChangeString(int n)&&& {&&& &switch (n)&&& &{&&& &&&& case 0:&&& &&&& &tv.append("石头\n");&&& &&&& &&&& &&&& case 1:&&& &&&& &tv.append("剪刀\n");&&& &&&& &&&& &&&& case 2:&&& &&&& &tv.append("布\n");&&& &&&& &&&& &&&& default:&&& &&&& &Toast.makeText(secondActivity.this, "错误", Toast.LENGTH_LONG).show();&&& &&&& &&&& &}&&& }&&&
3. 屏幕1跳转到屏幕2,屏幕2执行结束后有返回值到屏幕1(带返回值跳转)
参考示例程序:ReceiveResult(ApiDemo =&&& App=&Activity=&ReceiveResult)
重要代码:
& //屏幕1调转到屏幕2
&& Intent intent = new&& Intent(Forward.this,ForwardTargetActivity.class);
&& startActivityForResult(intent, GET_CODE);
&& //在屏幕2设置返回值
&& setResult(RESULT_OK,(new Intent()).setAction("Violet!"));
&& finish();
&& //在屏幕1得到从屏幕2返回的内容
&& @Override
&&& protected void onActivityResult(int RequestCode,int ResultCode,Intent data)
&&&& if(RequestCode == GET_CODE)
&&&& if(ResultCode == RESULT_CANCELED)
&&&& edit.append("canceled!");
&&&& edit.append("(okay ");
&&&& edit.append(Integer.toString(ResultCode));
&&&& edit.append(")");
&&&& if(data!=null)
&&&& edit.append(data.getAction());
&&&& edit.append("\n");
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具10:46 提问
Activity页面跳转怎样实现从下往上覆盖的效果
在网上搜索基本实现了activity跳转从下往上的功能,但是效果不是覆盖的感觉而是底下的activity变没了之后,怎么让底下的activity感觉是被另一个activity是从下被覆盖掉的。
按赞数排序
activity.overridePendingTransition(进场动画, 出场动画);
在启动跳转的地方添加overridePendingTransition(int resId,int resId);这两个参数分别为你自己新建的动画的资源id
从下滑进动画:
&?xml version="1.0" encoding="utf-8"?&
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="-100%p"
android:toYDelta="0" /&
从下滑出动画:
&?xml version="1.0" encoding="utf-8"?&
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0"
android:toYDelta="100%p" /&
activity.overridePendingTransition(进, 出);
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐Android基础页面跳转3 - ZHYFXY的博客 - CSDN博客
Android基础页面跳转3
带返回值的页面跳转
当跳转页面时调用startActivityForResult()
当使用startActivityForResult()方法跳转页面时,当调用完毕即跳转到的新的页面关闭时,回头再调用
protected void onActivityResult(int requestCode, int resultCode, Intent data)
Toast提示框的使用
Toast.makeText(this,&你关闭了第二个页面,现在返回第一个页面&,Toast.LENGTH_SHORT).show();
Activity的四种启动模式
在Manifest文件中,&activity&标签的一个属性launchMode
standard: &这是默认的模式。各Activity压入任务栈中,可以无限多生成新的Activity对象,甚至允许自己跳转到自己页面。
singleTop:栈顶唯一,不允许自己跳转到自己,即在这种情况下,不会产生新的对象。
singleTask:任务栈唯一,当经过几轮跳转到自身页面时,如果发现任务栈中已经有了该类对象,不会再产生新的对象,而是直接将此对象提到栈顶,原先在其上的其他页面将全部被顶出(销毁)。
singleInstance:单实例模式,在整个任务栈中,只允许保留一个实例。如果发现了任务栈中已经有了该类对象,不会再产生新的对象,而是直接将此对象提到栈顶,原先在其上的其他页面对象将依次沉到栈的底部。
android.R --&SDK中提供的资源
D:\dev\Android\sdk\platforms\android-24\data\res\xxx\xxxx
如何从一个布局文件中获取布局容器对象?
答:需要使用一个LayoutInflater对象,将XML文件解析成View对象。
在Activity类中,可以直接调用getLayoutInflater()来获取LayoutInflater对象。
&&&&&&&&LayoutInflater inflater = getLayoutInflater();
&&&&&&&&GridLayout layout = (GridLayout) inflater.inflate(R.layout.gridlayout_demo,null);
注:第二个参数为null意味着获取的View对象不加入到任何容器中。
Android Studio新建一个模块(Module)是一个独立运行的App
基础控件——TextView
使用LayoutInflater类的inflate方法从xml布局文件中解析出Java对象
总体从xml布局文件中解析出View容器对象,然后再执行
setContentView(R.layout.ll);
在此容器中可以任意添加自定义控件,具有更高的灵活性
控件的图文混排,即文字的上下左右都可以旋转图片,进行图文混排
drawableTop
drawableBottom
drawableLeft(drawableStart)
drawableRight(drawableEnd)
控件引用Drawable资源,自定义Drawable资源,需要在drawble目录下新建一个Drawble资源文件。
使用XML文件来描述形状,标签shape下面的属性定义:
corners:圆角属性
gradient:渐变属性
padding:填充属性
size:尺寸大小
solid:背景属性
stroke:线条属性
2.Selector
选择器(Selector)本身也是Drawable对象,某种操作会根据不同的情况显示不同的效果。
案例:华清选课App,模仿微信的操作界面。
图片做控件的背景,控件的大小和形状就会和图片一致
使用Photoshop做一个按钮的背景,颜色是#00C9B0,普通图片作为背景,在长宽不同比例的拉伸下,圆角变形。此时需要用到九宫格图片,即9patch图片。
它本身也是png图片,但在外面的边缘各增加一个像素点用来自定义拉伸的区域,文字填充区域。
SDK中提供一个叫draw9patch的工具,用来编辑九宫格图片。
左边和上边画线的投影交集部分为可拉伸区域
下边和右边画线的投影交集部分为文字显示区域
求得设备屏幕的宽、高像素以及分辨率:
&&&&&&&&int width = getResources().getDisplayMetrics().widthP
&&&&&&&&int height = getResources().getDisplayMetrics().heightP
&&&&&&&&int dpi = getResources().getDisplayMetrics().densityD
样式与主题
将控件的属性成批量地设置某种固定的值,作用于单个控件叫样式使用style属性名,
作用于Application和Activity的属性上叫主题,使用theme属性名。
显示的文字以系统设置的语言为标准,在不同的语言环境中,显示不同的文字。
例如:中国中文,新建一个目录values-zh,将strings.xml文件拷贝其中,将所有的常量字符串汉化;当系统设置为默认语言为简体中文时,界面就会以中文显示。
LANG=zh_CN.UTF-8
LANG=en_US.UTF-8
/etc/sysconfig/i18n
横屏与竖屏
专门针对横屏与竖屏的资源配置,可以将资源目录加上后缀。
在Manifest中,&activity&标签指定
&&&&&&&&&&&&android:screenOrientation=&portrait& ----》竖屏
&&&&&&&&&&&&android:screenOrientation=&landscape&----》横屏
在屏幕方向发生变化时,会销毁界面并重建,销毁以前把已经输入的数据保存在缓存中,屏幕变化后数据自动恢复,数据的保存与恢复是与控件的ID相绑定。
横屏与竖屏都可以单独地设计界面。后缀加上-land -port &例如:layout-land(横屏)和layout-port(竖屏)
屏幕旋转机制
判断屏幕是横屏或是竖屏
public static boolean isScreenOriatationPortrait(Context context)
&&&&&&return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
代码动态设置横屏与竖屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//横屏设置
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//竖屏设置
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
//默认设置
在屏幕旋转时,默认行为系统在销毁界面之前自动调用onSaveInstanceState方法保存用户输入的数据。而在重新创建界面时,在执行onCreate()方法时,传入的参数Bundle savedInstanceState对象就不为null
相关文章推荐Android实现页面跳转的几种方式
第一种方式,用action来跳转。
1、使用Action跳转,如果有一个的
AndroidManifest.xml中的某一个Activity的IntentFilter段中定义了包含了相同的Action那么这个Intent
就与这个目标Action匹配。如果这个IntentFilter段中没有定义 Type,Category,那么这个
Activity就匹配了。但是如果手机中有两个以上的匹配,那么就会弹出一个对话可框来提示说明。
Action的值在Android中有很多预定义,如果你想直接转到你自己定义的Intent接收者,你可以在接收者的
IntentFilter中加入一个自定义的Action值(同时要设定
Category值为"android.intent.category.DEFAULT"),在你的Intent中设定该值为Intent的
Action,就直接能跳转到你自己的Intent接收者中。因为这个Action在系统中是唯一的。
2,data/type,你可以用Uri来做为data,比如Uri uri =
Uri.parse(http://www.google.com);
Intent i = new
Intent(Intent.ACTION_VIEW,uri);手机的Intent分发过程中,会根据http://www.google.com
的scheme判断出数据类型type
手机的Brower则能匹配它,在Brower的Manifest.xml中的IntenFilter中首先有ACTION_VIEW
Action,也能处理http:的type。
3,至于分类Category,一般不要去在Intent中设置它,如果你写Intent的接收者,就在Manifest.xml的
Activity的 IntentFilter中包含android.category.DEFAULT,这样所有不设置
Category(Intent.addCategory(String
c);)的Intent都会与这个Category匹配。
4,extras(附加信息),是其它所有附加信息的集合。使用extras可以为提供扩展信息,比如,如果要执行“发送电子邮件”这个动作,可以将电子邮件的标题、正文等保存在extras里,传给电子邮件发送。
Java代码 package com.android.edit_&
import android.app.A&
import android.content.I&
import android.os.B&
import android.view.KeyE&
import android.view.V&
import android.widget.EditT&
public class MyEditText extends Activity
private TextView m_TextV&
private EditText m_EditT&
@Override&
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);&
setContentView(R.layout.main);&
& m_EditText = (EditText)
this.findViewById(R.id.EditText01);&
m_EditText.setOnKeyListener(editTextKeyListener);&
private EditText.OnKeyListener editTextKeyListener = new
EditText.OnKeyListener() {&
& @Override&
& public boolean onKey(View arg0, int arg1,
KeyEvent arg2) {&
action跳转,需要在AndroidManifest.xml中配置action&
& & Intent i = new
Intent("android.intent.action.mydialog");&
MyEditText.this.startActivity(i);&
& & return
复制代码Xml代码 &?xml version="1.0"
encoding="utf-8"?&&
xmlns:android="http://schemas.android.com/apk/res/android"&
package="com.android.edit_text"
android:versionCode="1"&
android:versionName="1.0"&&
&application android:icon="@drawable/icon"
android:label="@string/app_name"&&
& &activity
android:name=".MyEditText"
android:label="@string/app_name"&&
&intent-filter&&
android:name="android.intent.action.MAIN"
&&category
android:name="android.intent.category.LAUNCHER"
&/intent-filter&&
&/activity&&
&&!--配置跳转activity--&&
& &activity
android:name="com.android.dialog.MyDialog"&&
&intent-filter&&
&!--配置action路径--&&
android:name="android.intent.action.mydialog"
&&category
android:name="android.intent.category.DEFAULT"
&/intent-filter&&
&/activity&&
&/application&&
&uses-sdk android:minSdkVersion="7"
&/manifest&&
复制代码第二种方式,用类名跳转。
Intent负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述,Android则根据此Intent的描述,
负责找到对应的,将
Intent传递给调用的,并完成的调用。Intent在这里起着实现调用者与被调用者之间的解耦作用。
Intent传递过程中,要找到目标消费者(另一个Activity,IntentReceiver或Service),也就是Intent的响应者。
Java代码 package com.A&
import android.app.A&
import android.content.I&
import android.os.B&
import android.view.V&
android.view.View.OnClickL&
public class FormStuff extends Activity
@Override&
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);&
setContentView(R.layout.formstuff);&
& final ImageButton button = (ImageButton)
findViewById(R.id.android_button);&
& button.setOnClickListener(new OnClickListener()
& & public void onClick(View v)
用类名跳转,需要在AndroidManifest.xml中申明activity&
&Intent intent = new Intent(FormStuff.this,
HelloTabWidget.class);&
&startActivity(intent);&
复制代码Xml代码 &?xml version="1.0"
encoding="utf-8"?&&
xmlns:android="http://schemas.android.com/apk/res/android"&
package="com.Android" android:versionCode="1"
android:versionName="1.0"&&
&application android:icon="@drawable/icon"
android:theme="@android:style/Theme.NoTitleBar"&&
& &activity
android:name=".FormStuff"
android:label="@string/app_name"&&
&intent-filter&&
android:name="android.intent.action.MAIN"
&&category
android:name="android.intent.category.LAUNCHER"
&/intent-filter&&
&/activity&&
&!--申明activity--&&
android:name="HelloTabWidget"&&/activity&&
&/application&&
&uses-sdk android:minSdkVersion="4"
&/manifest&&
复制代码一些Intent的常用发:
Java代码 显示网页&
1. Uri uri =
Uri.parse("http://google.com");&
2. Intent it = new Intent(Intent.ACTION_VIEW,
3. startActivity(it);&
1. Uri uri =
Uri.parse("geo:38..036476");&
2. Intent it = new Intent(Intent.ACTION_VIEW,
3. startActivity(it);&
4. //其他 geo URI 範例&
5. //geo:latitude,longitude&
6. //geo:latitude,longitude?z=zoom&
7. //geo:0,0?q=my+street+address&
8. //geo:0,0?q=business+near+city&
//google.streetview:cbll=lat,lng&cbp=1,yaw,,pitch,zoom&mz=mapZoom
1. Uri uri =
Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat
startLng&daddr=endLat
endLng&hl=en");&
2. Intent it = new Intent(Intent.ACTION_VIEW,
3. startActivity(it);&
4. //where startLat, startLng, endLat, endLng are a long with
6 decimals like: 50.123456&
1. //叫出拨号
2. Uri uri =
Uri.parse("tel:");&
3. Intent it = new Intent(Intent.ACTION_DIAL,
4. startActivity(it);&
1. //直接打电话出去&
2. Uri uri =
Uri.parse("tel:");&
3. Intent it = new Intent(Intent.ACTION_CALL,
4. startActivity(it);&
5. //用這个,要在 AndroidManifest.xml 中,加上&
6. //&uses-permission
id="android.permission.CALL_PHONE"
传送SMS/MMS&
1. //调用短信
2. Intent it = new Intent(Intent.ACTION_VIEW,
3. it.putExtra("sms_body", "The SMS
it.setType("vnd.android-dir/mms-sms");&
5. startActivity(it);
1. //传送消息 &&
2. Uri uri =
Uri.parse("smsto://");&
3. Intent it = new Intent(Intent.ACTION_SENDTO,
4. it.putExtra("sms_body", "The SMS
5. startActivity(it);
1. //传送 MMS&
2. Uri uri =
Uri.parse("content://media/external/images/media/23");&
3. Intent it = new
Intent(Intent.ACTION_SEND);&
4. it.putExtra("sms_body", "some
5. it.putExtra(Intent.EXTRA_STREAM,
6. it.setType("image/png");&
7. startActivity(it);&
传送 Email&
1. Uri uri =
Uri.parse("mailto:");&
2. Intent it = new Intent(Intent.ACTION_SENDTO,
3. startActivity(it);&
1. Intent it = new
Intent(Intent.ACTION_SEND);&
2. it.putExtra(Intent.EXTRA_EMAIL,
3. it.putExtra(Intent.EXTRA_TEXT, "The email body
4. it.setType("text/plain");&
5. startActivity(Intent.createChooser(it, "Choose Email
Client"));&
1. Intent it=new Intent(Intent.ACTION_SEND);
2. String[] tos={""}; &
3. String[] ccs={""}; &
4. it.putExtra(Intent.EXTRA_EMAIL, tos); &
5. it.putExtra(Intent.EXTRA_CC, ccs); &
6. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
7. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject
8. it.setType("message/rfc822"); &
9. startActivity(Intent.createChooser(it, "Choose Email
Client")); &&
1. //传送附件&
2. Intent it = new
Intent(Intent.ACTION_SEND);&
3. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject
4. it.putExtra(Intent.EXTRA_STREAM,
"file:///sdcard/mysong.mp3");&
5. sendIntent.setType("audio/mp3");&
6. startActivity(Intent.createChooser(it, "Choose Email
Client")); &&
播放多媒体&
&& Uri uri =
Uri.parse("file:///sdcard/song.mp3");&
&& Intent it = new
Intent(Intent.ACTION_VIEW, uri);&
it.setType("audio/mp3");&
&& startActivity(it);
&& Uri uri =
Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,
&& Intent it = new
Intent(Intent.ACTION_VIEW, uri);&
&& startActivity(it);
Market 相关&
&//寻找某个应用
&Uri uri =
Uri.parse("market://search?q=pname:pkg_name");
&Intent it = new Intent(Intent.ACTION_VIEW,
&startActivity(it);&
&//where pkg_name is the full package path for an
application &&
&//显示某个应用的相关信息
&Uri uri =
Uri.parse("market://details?id=app_id");&
&Intent it = new Intent(Intent.ACTION_VIEW, uri);
&startActivity(it);&
&//where app_id is the application ID, find the
&//by clicking on your application on Market
&//page, and notice the ID from the address bar
&Uri uri = Uri.fromParts("package",
strPackageName, null); &&
&Intent it = new Intent(Intent.ACTION_DELETE,
&startActivity(it); &
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 页面跳转触发事件 的文章

 

随机推荐