Back to project page QuantiModo-SDK-Android.
The source code is released under:
GNU General Public License
If you think the Android project QuantiModo-SDK-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.quantimodo.android.sdk; /*w w w.j a va 2 s . co m*/ import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; public class Quantimodo { public static boolean isInstalled(Context context) { try { PackageManager pm = context.getPackageManager(); pm.getPackageInfo("com.quantimodo.android", PackageManager.GET_META_DATA); return true; } catch (PackageManager.NameNotFoundException e) { return false; } } public static Intent getInstallIntent() { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.quantimodo.android")); return intent; } public static Intent getLoginIntent(Context context) { Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.quantimodo.android"); intent.setFlags(intent.getFlags() & (~Intent.FLAG_ACTIVITY_NEW_TASK)); // Open sign in activity in same task intent.setAction("com.quantimodo.android.ACTION_SIGN_IN"); intent.putExtra("callingApp", context.getPackageName()); return intent; } public static Account[] getAccounts(Context context) { return AccountManager.get(context).getAccountsByType("com.quantimodo"); } public static Account getAccount(Context context) { Account[] accounts = getAccounts(context); if (accounts.length > 0) { return accounts[0]; } else { return null; } } public static Account getAccount(Context context, String name) { Account[] accounts = getAccounts(context); for (Account account : accounts) { if (account.name.equals(name)) { return account; } } return null; } }