标签:android style http java 使用 os io 文件
一、基本知识点
1、<activity android:label="第一个activity" android:name=".Main2Activity"/>
label属性:某个Acivity的标题
startActivity(intent);
二、举例
1、MainActivity
package com.example.multiactivity; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; 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.main); } public void open(View view){ int id = view.getId(); if(id == R.id.open1){ /** * 以下演示了显示意图激活的5种方式 */ // Intent intent = new Intent(); // intent.setClass(this, MainActivity2.class); // intent.setClassName(this, "com.example.multiactivity.MainActivity2"); // System.out.println("---------->" + getPackageName()); // intent.setClassName(getPackageName(), "com.example.multiactivity.MainActivity2");//注意了第二个参数都是全类名 // intent.setComponent(new ComponentName(this, MainActivity2.class)); Intent intent = new Intent(this, MainActivity2.class); startActivity(intent); }else if(id == R.id.open2){ Intent intent = new Intent(); intent.setAction("hellointent"); // intent.setData(Uri.parse("zhangzetian:")); // intent.setType("image/jpeg"); intent.setDataAndType(Uri.parse("zhangzetian:"), "image/jpeg"); startActivity(intent); }else if(id == R.id.open3){ Intent intent = new Intent(); intent.setAction(("android.intent.action.VIEW")); intent.setData(Uri.parse("http://www.baidu.com")); startActivity(intent); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
2、MainActivity2
package com.example.multiactivity; import android.app.Activity; import android.os.Bundle; public class MainActivity2 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); } }
3、MainActivity3
package com.example.multiactivity; import android.app.Activity; import android.os.Bundle; public class MainActivity3 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main3); } }
4、在显示意图激活和隐式意图激活的过程中,其实AndroidManifest.xml文件是很重要的。故在此附上AndroidManifest.xml的全部代码:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.multiactivity" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.multiactivity.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="com.example.multiactivity.MainActivity2" android:label="这是第二个Activity" /> <activity android:name="com.example.multiactivity.MainActivity3"> <intent-filter > <action android:name="hellointent"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="asdasd"/> <data android:scheme="zhangzetian" android:mimeType="image/jpeg"/> </intent-filter> </activity> </application> </manifest>
三、源码下载:
http://download.csdn.net/detail/caihongshijie6/7792167
(Android review)显示意图激活与隐式意图激活,布布扣,bubuko.com
标签:android style http java 使用 os io 文件
原文地址:http://blog.csdn.net/hjd_love_zzt/article/details/38708941