Skip to content

Instantly share code, notes, and snippets.

@s-shin
Created September 7, 2014 08:59
Show Gist options
  • Select an option

  • Save s-shin/c108624fca0f82554376 to your computer and use it in GitHub Desktop.

Select an option

Save s-shin/c108624fca0f82554376 to your computer and use it in GitHub Desktop.
Hotentorで作ったIntentユーティリティから抜粋。
package jp.hateblo.shin.hotentor.util;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import jp.hateblo.shin.hotentor.App;
/**
* Created by shin on 2014/08/31.
*/
public class IntentUtil {
public static boolean isAppInstalled(String appId) {
try {
App.getAppContext().getPackageManager()
.getApplicationInfo(appId, PackageManager.GET_META_DATA);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public static void sendIntentWithUrl(Context activity, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
activity.startActivity(intent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment