我想從我的應用程序打開優步應用程序。但我沒有得到適當的代碼it.please建議一些code.I搜索了幾個網站,但沒有得到正確的code.please提供一些代碼從我的應用程序打開超級應用程序。從我的應用程序打開優步應用程序android
0
A
回答
3
你可以試試下面的代碼
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo("com.ubercab", PackageManager.GET_ACTIVITIES);
String uri = "uber://?action=setPickup&pickup=my_location";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
startActivity(intent);
} catch (PackageManager.NameNotFoundException e) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.ubercab")));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.ubercab")));
}
}
+0
,但它正在打開應用程序在playstore.I已經超級安裝。 – Mainak
+0
請檢查更新的代碼 –
0
你需要在你的清單做到這樣,那就是爲我工作。
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|keyboard|screenSize"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="yoursitedomain.com"
android:scheme="http" />
<data
android:host="www.yoursitedomain.com"
android:scheme="http" />
</intent-filter>
</activity>
2
用於打開Uber應用你需要整合尤伯杯SDK與您App.Check下面的鏈接https://github.com/uber/rides-android-sdk
0
我覺得這是我們推出Android應用中的其他應用程序的更好的方法。
// Pojo Model to handle application info
public class AppInfo {
private boolean isInstalled;
private ApplicationInfo applicationInfo;
public AppInfo(boolean isInstalled, ApplicationInfo applicationInfo) {
this.isInstalled = isInstalled;
this.applicationInfo = applicationInfo;
}
public boolean isInstalled() {
return isInstalled;
}
public void setInstalled(boolean installed) {
isInstalled = installed;
}
public ApplicationInfo getApplicationInfo() {
return applicationInfo;
}
public void setApplicationInfo(ApplicationInfo applicationInfo) {
this.applicationInfo = applicationInfo;
}
}
// Check Uber is installed or not
private AppInfo isUberAppsAvailable() {
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
int size = (null != packages && !packages.isEmpty()) ? packages.size() : 0;
for(int index = 0; index < size; index++) {
ApplicationInfo packageInfo = packages.get(index);
String packageName = (null != packageInfo) ? packageInfo.packageName : null;
if(null != packageName && packageName.equalsIgnoreCase(CJRConstants.PACKAGE_INFO_UBER)){
return new AppInfo(true, packageInfo);
}
}
return new AppInfo(false, null);
}
// Launch Uber App.
private void launchAppByPackage() {
AppInfo uberAppInfo = isUberAppsAvailable();
boolean isUberInstalled = (null != uberAppInfo
&& null != uberAppInfo.getApplicationInfo()
&& uberAppInfo.getApplicationInfo().enabled) ? uberAppInfo.isInstalled() : false;
if(isUberInstalled) {
ApplicationInfo uberObj = uberAppInfo.getApplicationInfo();
Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage(uberObj.packageName);
startActivity(LaunchIntent);
} else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.ubercab")));
}
}
相關問題
- 1. 打開一個應用程序從我的Android應用程序
- 2. 我想從android應用程序打開日曆應用程序
- 3. 在我的Android應用程序中打開vimeo應用程序?
- 4. 從我的應用程序打開Facebook應用程序
- 5. 從我的應用程序打開Foursquare應用程序
- 6. 如何從我的應用程序打開ola應用程序?
- 7. 從我的應用程序中打開iPod應用程序?
- 8. 從我的iPhone應用程序打開Spotify應用程序
- 9. 從我的iOS 5應用程序打開Twitter應用程序
- 10. 從我的應用程序打開另一個應用程序?
- 11. android:我如何從我的應用程序打開另一個應用程序?
- 12. 如何從我的android應用程序中打開LinkedIn應用程序?
- 13. 從我的應用程序打開iBooks
- 14. 從我的應用程序打開iMessage
- 15. 從android webview打開youtube應用程序
- 16. 從Android應用程序打開Gmail
- 17. 從後臺打開android應用程序
- 18. 優步深度Android應用程序
- 19. 我想從Xamarin Android應用程序打開應用程序設置頁面
- 20. Phonegap Android應用程序,打開應用程序內的鏈接?
- 21. 如何用Android應用程序打開Facebook應用程序?
- 22. 我的Android應用程序崩潰,當我打開應用程序(不幸的應用程序已停止)
- 23. 在我的應用程序中打開「消息」應用程序
- 24. 在我的應用程序中打開外部應用程序
- 25. 從Unix應用程序開始/逐步掃描應用程序
- 26. 從iOS中的後臺應用程序打開應用程序?
- 27. 從經典的asp.net應用程序打開mvc應用程序
- 28. 從其他應用程序打開您的應用程序
- 29. 從通用Windows應用程序打開外部應用程序
- 30. 我可以從我的應用程序打開設置應用程序嗎?
您是否知道要打開的優步應用程序活動的名稱?你可以發送一個明確的意圖打開它 – AADProgramming