0
私はAndroidスタジオにはかなり新しく、2つのマップアプリの中から選択する可能性がアプリに追加されました。しかし、私は悪名高い "Always open/just once"メソッドを追加する方法を知りたがっています。いつも一度だけメソッドを追加するには?
private void launchNextActivity(String latitude, String longitude, int state) {
for (int i = 0; i < User.getUserCourses().size(); i++) {
if (User.getUserCourses().get(i).getIdCourse() == course.getIdCourse()) {
//A remplacer par l'appel de l'api
Intent intent;
Location location = getLastKnownLocation();
if (location == null) {
Toast.makeText(getApplicationContext(), "Connexion avec le serveur impossible", Toast.LENGTH_SHORT).show();
return;
}
String uri = "google.navigation:q=" + latitude + "+" + longitude;
uri = uri.replace(" ", "+");
intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(uri)).setPackage("com.google.android.apps.maps");
if (intent == null) {
findViewById(R.id.cancel_button).setClickable(false);
Snackbar
.make(findViewById(R.id.snackbar_position), "Google Map missing", Snackbar.LENGTH_LONG)
.setAction("Download", new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps")));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.apps.maps")));
}
findViewById(R.id.cancel_button).setClickable(true);
}
})
.setActionTextColor(getResources().getColor(R.color.ShGreen2))
.show();
}
//Load Waze if available
Intent wazeIntent;
String uriWaze = "https://waze.com/ul?ll=" + latitude + "," + longitude + "&navigate=yes";
wazeIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uriWaze)).setPackage("com.waze");
Intent chooserIntent = Intent.createChooser(intent, "Ouvrir l'itinéraire avec:");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { wazeIntent });
reloadActivity(state, chooserIntent);
}
これは実際にどのように実際に動作するかに関する情報をほとんど一切検索していません。私は常に私はそれを常に起動する選択肢を呼び出すので、しかし、どのように "いつも/ 1回だけ"を選択せずに開いて追加することを知っていますか?
ありがとうございます!それはまさに私が必要なものでした!今は完璧に動作します。 ^^ – Max