Created
June 30, 2014 09:46
-
-
Save b1lb0/15eacbec64b36d867e1a to your computer and use it in GitHub Desktop.
codice app terze
This file contains 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
public class KimStart extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
mock_loginok_paid(); | |
} | |
private void mock_loginok_paid(){ | |
Uri url = Uri.parse("kim://com.buongiorno.kim.LOGINOK_PAID"); | |
//Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.buongiorno.kim"); | |
//launchIntent.setAction("com.buongiorno.kim.LOGINOK_PAID"); | |
//startActivityForResult(launchIntent, 1001); | |
Intent intent = new Intent("android.intent.action.VIEW" , url); | |
PackageManager packageManager = getPackageManager(); | |
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); | |
boolean isIntentSafe = activities.size() > 0; | |
if (isIntentSafe) { | |
Log.d("KIM CLIENT", "calling.... kim://com.buongiorno.kim.LOGINOK_PAID"); | |
startActivityForResult(intent, 1001); | |
} else { | |
Log.d("KIM CLIENT", "KIM non installed"); | |
} | |
//Intent intent = new Intent("com.buongiorno.kim.LOGINOK_PAID"); | |
//sendBroadcast(intent); | |
} | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
if (requestCode == 1001 && data != null) { | |
Intent response = data; | |
String user_id = data.getStringExtra("user_id"); | |
boolean is_logged = data.getBooleanExtra("is_logged", false); | |
boolean is_paid = data.getBooleanExtra("is_paid", false); | |
long end_date = data.getLongExtra("end_date", 0); | |
Log.d("KIM CLIENT","app:"+getPackageName()+ " get result:"+resultCode+" is_logged"+is_logged); | |
/* | |
result.putExtra("is_logged",(Settings.getUserId() != null) ? true : false); | |
result.putExtra("is_paid",Settings.isPaid()); | |
result.putExtra("user_id", Settings.getUserId()); | |
result.putExtra("end_date",(System.currentTimeMillis()/1000)+100); | |
*/ | |
} | |
startActivity(new Intent(getBaseContext(), com.appsfuelgames.testclient.app.KimStart.class)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment