From 927d2cd19fc95f6a423e4325e8bee9515d924162 Mon Sep 17 00:00:00 2001 From: lilifeuj Date: Sat, 26 May 2018 04:22:55 +0200 Subject: [PATCH] bouton appli --- Appli/Main2Activity.java | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Appli/Main2Activity.java diff --git a/Appli/Main2Activity.java b/Appli/Main2Activity.java new file mode 100644 index 0000000..819e92a --- /dev/null +++ b/Appli/Main2Activity.java @@ -0,0 +1,53 @@ +package com.example.nicolas.myapplication; + +import android.content.Intent; +import android.net.Uri; +import android.provider.MediaStore; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +public class Main2Activity extends AppCompatActivity { + + Button button_map; + Button button_photo; + Button button_gallery; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main2); + + button_gallery = findViewById(R.id.button_gallery); + button_map = findViewById(R.id.button_map); + button_photo = findViewById(R.id.button_photo); + + button_gallery.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_VIEW, null); + intent.setType("image/*"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + }); + + button_photo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + if (intent.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent, 0); + } + }}); + + button_map.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393")); + startActivity(intent); + } + }); + } +}