㈠ android 應用調用另外一個應用的activity
這個首先你要知道app2的activity的名字才行。你知道了就簡單了,不知道的話,只能通過log一個個的看。比如app2中有個activity的名字為MyActivity,完整的包名是com.example.app2.MyActivity.那麼你從app1跳過去可以這樣跳:
Intent in = new Intent();
in.setClassName("com.example.app2", "com.example.app2.MyActivity");
mContext.startActivity(in);
㈡ android中一個應用程序如何調用到另一個另一程序的activity
生成一個要被調用的APK。在其Manifest.xml設置中,與一般的寫法大致相同,唯一區別的地方在於-->安裝這個要被調用的APK。安裝完畢之後,你會發現,系統中找不到這個程序。別急,它確實安裝在手機裡面了,但是因為他不是main的,所以系統不會把他當做Application的入口程序。而要想打開這個activity,只有知道它名字的人才可以。跟系統的intent一樣使用。它的名字定義為"testApp",所以,這里用這個字元串就可以調用它了在另一個項目中調用上述APK。代碼如下java">Intentintent=newIntent("testApp");startActivity(intent);啟動另外一個apkjava">IntentmIntent=newIntent();ComponentNamecomp=newComponentName(packageName,activityName);mIntent.setComponent(comp);mIntent.setAction("android.intent.action.VIEW");startActivity(mIntent);
㈢ Android 調用其他應用打開文件
/**
*打開文件
*@paramfile
*/
privatevoidopenFile(Filefile){
Intentintent=newIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//設置intent的Action屬性
intent.setAction(Intent.ACTION_VIEW);
//獲取文件file的MIME類型
Stringtype=getMIMEType(file);
//設置intent的data和Type屬性。
intent.setDataAndType(/*uri*/Uri.fromFile(file),type);
//跳轉
startActivity(intent);
}
/**
*根據文件後綴名獲得對應的MIME類型。
*@paramfile
*/
privateStringgetMIMEType(Filefile){
Stringtype="*/*";
StringfName=file.getName();
//獲取後綴名前的分隔符"."在fName中的位置。
intdotIndex=fName.lastIndexOf(".");
if(dotIndex<0){
returntype;
}
/*獲取文件的後綴名*/
Stringend=fName.substring(dotIndex,fName.length()).toLowerCase();
if(end=="")returntype;
//在MIME和文件類型的匹配表中找到對應的MIME類型。
for(inti=0;i<MIME_MapTable.length;i++){//MIME_MapTable??在這里你一定有疑問,這個MIME_MapTable是什麼?
if(end.equals(MIME_MapTable[i][0]))
type=MIME_MapTable[i][1];
}
returntype;
}具體的看這篇文章http://tonysun3544.iteye.com/blog/1265884
㈣ android兩個應用程序之間的通信和調用
你是說兩個應用之間還是單個應用的進程之間?
應用程序之間共享數據其實可以使用shareperference 或者 sqlite就行 只是實時操作而已 系統資源消耗比較大。
如果是線程間通信可以使用類似handler和runable傳參數。
如果是進程間通信的話可以使用遠程服務,AIDL作為中間介面,一個服務端一個客戶端數據就可以交互。
㈤ Android開發 我想讓應用程序可以在別的應用調用瀏覽器的時候調用它,請問應該怎麼做
如果想要對方應用點擊鏈接後直接調用你的瀏覽器打開,那是無法實現的(除非只裝了你這一個瀏覽器)。
首先你應該了解,android中打開activity或者service是通過發送intent去執行的,而intent又有隱性和顯性之分。
只有對方應用創建的是顯性intent並指定了你開發的瀏覽器,那麼才會直接以你的瀏覽器打開網頁,
但這個intent是由發送方決定的,你作為瀏覽器的開發者是無可奈何的。
你能做的只是開發一個broadcastReceiver(廣播接收器),告訴系統你是一個瀏覽器,
那麼當用戶用隱式intent去打開瀏覽器時,你就會作為一個備選瀏覽器供用戶選擇。
㈥ Android怎樣在應用中啟動另一個應用並放在後台運行
啟動另一個應用:
Intent intent = new Intent();
intent.setClassName("目標應用的包名", "目標應用的目標Activity");
startActivity(intent);
後台運行就只能啟動目標應用的Service,即目標應用的目標Activity是一個Service。
㈦ 如何通過android的應用程序調用另一個應用
如果你知道另外一個程序的類名就可以這樣寫
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentNamecn=newComponentName(packageName,className);
intent.setComponent(cn);
startActivity(intent);
2.如果你只知道包名不知道類名,首先獲取類名
privatevoidopenApp(StringpackageName){
PackageInfopi=getPackageManager().getPackageInfo(packageName,0);
IntentresolveIntent=newIntent(Intent.ACTION_MAIN,null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
resolveIntent.setPackage(pi.packageName);
List<ResolveInfo>apps=pm.queryIntentActivities(resolveIntent,0);
ResolveInfori=apps.iterator().next();
if(ri!=null){
StringpackageName=ri.activityInfo.packageName;
StringclassName=ri.activityInfo.name;
Intentintent=newIntent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentNamecn=newComponentName(packageName,className);
intent.setComponent(cn);
startActivity(intent);
}
}
然後使用1中的方法調用程序
㈧ 如何在一個android應用裡面調用一個系統的應用程序呢
//調用系統照相機
public void cameraInfo(){
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
//照片保存的路徑及保存的名稱
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(new File("/sdcard/JetMobileDev/camera.jpg"));
startActivityForResult(intent, 1);
}
㈨ Android如何實現不同應用之間的調用
使用ComponentName()可以跳轉到任何一個activity,不論是不是main activity。也不必寫修改被調用的apk的AndroidManifest.xml任何內容,如下:
packagecom.hooy.apk1;
importandroid.app.Activity;
importandroid.content.ComponentName;
importandroid.content.Intent;
importandroid.os.Bundle;
importandroid.view.MotionEvent;
{
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
publicbooleanonTouchEvent(MotionEventevent){
ComponentNamecomponetName=newComponentName(
//這個是另外一個應用程序的包名
"com.hooy.apk2",
//這個參數是要啟動的Activity
"com.hooy.apk2.Pay_Activity");
//Intentintent=newIntent("chroya.foo");
Intentintent=newIntent();
//我們給他添加一個參數表示從apk1傳過去的
Bundlebundle=newBundle();
bundle.putString("arge1","這是跳轉過來的!來自apk1");
intent.putExtras(bundle);
intent.setComponent(componetName);
startActivity(intent);
returnsuper.onTouchEvent(event);
}
}
ComponentName的參數已經寫的比較詳細了
packagecom.hooy.apk2;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.os.Bundle;
importandroid.widget.TextView;
publicclassPay_ActivityextendsActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//改變文字內容,標志這是從activity跳轉過來的
TextViewtexView=(TextView)findViewById(R.id.text1);
texView.setText("我來自其他activity");
Intentintent=getIntent();
Stringvalue=intent.getStringExtra("arge1");
if(value!=null&&!value.equals("")){
texView.setText(value);//這里將顯示「這是跳轉過來的!來自apk1」
}else{
System.out.println("空的參數");
}
}
}
㈩ android Intent啟動其它應用
可以帶別的東西。
需要com.rarlab.rar.MainActivity類的支持。
com.rarlab.rar.MainActivity可以在onCreate中通過getIntent來得到
傳入來的intent.
intent可以設置一些數據,比如Intent.putExtra("type","rar")
然後onCreate得到後,可以Intent.getStringExtra("type")