Created
January 30, 2014 02:37
-
-
Save long-nguyen/8701601 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressLint("InlinedApi") | |
public static void launchApp(final String packageName,final String activityName,final String key,final String value){ | |
if(packageName==null||activityName==null) return ; | |
UnityPlayer.currentActivity.runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
try{ | |
final PackageManager pm = UnityPlayer.currentActivity.getPackageManager(); | |
Intent launchIntent = pm.getLaunchIntentForPackage(packageName); | |
if(launchIntent!=null){ | |
launchIntent.putExtra(key, value); | |
UnityPlayer.currentActivity.startActivity(launchIntent); | |
return; | |
} | |
}catch(Exception e){} | |
//Otherwise open google play | |
UnityPlayer.currentActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+packageName))); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment