Beiträge von json

    Ja, ich möchte meine eigene Icon auf den blauen Punkt legen oder ersetzen, aber ich möchte dass mein Ort (die Icon / Blaue Punkt) immer in der Mitte.


    d.h. wenn ich bewege, dann soll die karte bewegen, damit mein Icon immer in der Mitte bleibt.


    Google Map macht das nicht, man muss ständig auf das Icon oben (mein Ort) klicken.


    mit andren worten, wir simulieren ständig einen Klick auf mylocation-Icon.


    shau das Foto an. der blaue Punkt ist nicht in der Mitte vom Bildschirm
    [Blockierte Grafik: https://i.stack.imgur.com/rKM0H.png]

    Hallo
    ich suche seit 2 Tagen den Code dafürm, das nein Ort (blauer Punkt) immer zentriert auf Bildschirm bleibt.


    Beim Laufen, soll der blaue Punkt (Mein Ort) in der Mitte vom Bildschirm, genauso wie Navigator


    wie macht man das in android studion ?

    Ich habe den code getestet, es funktioniert aber ich möchte das Bild schneiden
    hier ist der code complet von dem Beispiel dort
    kann jemand die Crop funktion drin einbauen ?


    package test.testing7;


    import android.app.Activity;
    import android.content.Intent;
    import android.database.Cursor;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.net.Uri;
    import android.os.Environment;
    import android.provider.MediaStore;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageView;


    import java.io.File;
    import java.util.Date;


    public class Camera1 extends AppCompatActivity {


    private String selectedImagePath = "";
    final private int PICK_IMAGE = 1;
    final private int CAPTURE_IMAGE = 2;



    String imgPath;
    Button btnGallery, btnCapture;


    ImageView imgUser;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera1);


    btnGallery= (Button) findViewById(R.id.btnGallery);
    btnCapture= (Button) findViewById(R.id.btnCapture);
    imgUser= (ImageView) findViewById(R.id.imgUser);



    btnGallery.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, ""), PICK_IMAGE);


    }
    });
    btnCapture.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, setImageUri());
    startActivityForResult(intent, CAPTURE_IMAGE);
    }
    });


    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_CANCELED) {
    if (requestCode == PICK_IMAGE) {
    selectedImagePath = getAbsolutePath(data.getData());
    imgUser.setImageBitmap(decodeFile(selectedImagePath));
    } else if (requestCode == CAPTURE_IMAGE) {
    selectedImagePath = getImagePath();
    imgUser.setImageBitmap(decodeFile(selectedImagePath));
    } else {
    super.onActivityResult(requestCode, resultCode, data);
    }
    }


    }


    public Uri setImageUri() {
    // Store image in dcim
    File file = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".png");
    Uri imgUri = Uri.fromFile(file);
    this.imgPath = file.getAbsolutePath();
    return imgUri;
    }


    public String getImagePath() {
    return imgPath;
    }


    public Bitmap decodeFile(String path) {
    try {
    // Decode image size
    BitmapFactory.Options o = new BitmapFactory.Options();
    o.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(path, o);
    // The new size we want to scale to
    final int REQUIRED_SIZE = 70;


    // Find the correct scale value. It should be the power of 2.
    int scale = 1;
    while (o.outWidth / scale / 2 >= REQUIRED_SIZE && o.outHeight / scale / 2 >= REQUIRED_SIZE)
    scale *= 2;


    // Decode with inSampleSize
    BitmapFactory.Options o2 = new BitmapFactory.Options();
    o2.inSampleSize = scale;
    return BitmapFactory.decodeFile(path, o2);
    } catch (Throwable e) {
    e.printStackTrace();
    }
    return null;


    }


    public String getAbsolutePath(Uri uri) {
    String[] projection = { MediaStore.MediaColumns.DATA };
    @SuppressWarnings("deprecation")
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    if (cursor != null) {
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
    } else
    return null;
    }



    }



    --------------------------------------------------------------

    Dieser Teil fehlt :



    private void performCrop(){
    try {
    //call the standard crop action intent (the user device may not support it)
    Intent cropIntent = new Intent("com.android.camera.action.CROP");
    //indicate image type and Uri
    cropIntent.setDataAndType(picUri, "image/*");
    //set crop properties
    cropIntent.putExtra("crop", "true");
    //indicate aspect of desired crop
    cropIntent.putExtra("aspectX", 100);
    cropIntent.putExtra("aspectY", 100);
    //indicate output X and Y
    cropIntent.putExtra("outputX", 100);
    cropIntent.putExtra("outputY", 200);
    cropIntent.putExtra("scale", true);
    //retrieve data on return
    cropIntent.putExtra("return-data", true);
    //start the activity - we handle returning in onActivityResult
    startActivityForResult(cropIntent, 4);
    //Toast toast = Toast.makeText(this, "Done", Toast.LENGTH_SHORT);
    }
    catch(ActivityNotFoundException anfe){
    //display an error message
    String errorMessage = "Whoops - your device doesn't support the crop action!";
    Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
    toast.show();
    }


    }

    ie Kamera startet
    Bild wird aufgenommen
    aber wenn ich klicke wieder auf OK um das Bid zu schneiden, dann bekomme ich schwarzen Bildschirm
    also d.h. OnResult liefert kein korekte uri für schneide-Funktion, denke ich oder ?
    package com.project.capture6;
    [Blockierte Grafik: https://picload.org/thumbnail/rpgpigor/capture6.jpg]













    import android.content.ActivityNotFoundException;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.net.Uri;
    import android.provider.MediaStore;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.text.Html;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.Toast;
    import java.io.IOException;


    public class Capture extends AppCompatActivity {
    //final int PIC_CROP=2;
    private Uri picUri;
    Bitmap bitmap,bitmap2,bitmap3;
    ImageView img,img_original;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_capture);



    img = (ImageView) findViewById(R.id.imageView);
    img_original = (ImageView) findViewById(R.id.imageView_original);
    }



    public void Capture(View view) {
    Capture_Cam();
    }



    private void Capture_Cam() {
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(cameraIntent, 1);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {



    if (requestCode == 1 && resultCode == RESULT_OK && data != null) {



    picUri = data.getData();
    try {
    // bitmap2 = MediaStore.Images.Media.getBitmap(this.getContentResolver(), picUri);
    bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), Uri.parse("file://"+picUri));
    img_original.setImageBitmap(bitmap);



    } catch (IOException e) {
    e.printStackTrace();
    }
    performCrop();


    } else if (requestCode == 2) {


    bitmap2=(Bitmap) data.getExtras().get("data");
    img.setImageBitmap(bitmap2);
    }else{
    super.onActivityResult(requestCode, resultCode, data);
    }
    }
    private void performCrop(){
    try {
    //call the standard crop action intent (the user device may not support it)
    Intent cropIntent = new Intent("com.android.camera.action.CROP");
    //indicate image type and Uri
    cropIntent.setDataAndType(picUri, "image/*");
    //set crop properties
    cropIntent.putExtra("crop", "true");
    //indicate aspect of desired crop
    cropIntent.putExtra("aspectX", 100);
    cropIntent.putExtra("aspectY", 100);
    //indicate output X and Y
    cropIntent.putExtra("outputX", 100);
    cropIntent.putExtra("outputY", 200);
    cropIntent.putExtra("scale", true);
    //retrieve data on return
    cropIntent.putExtra("return-data", true);
    //start the activity - we handle returning in onActivityResult
    startActivityForResult(cropIntent, 2);
    Toast toast = Toast.makeText(this, "Done", Toast.LENGTH_SHORT);
    }
    catch(ActivityNotFoundException anfe){
    //display an error message
    String errorMessage = "Whoops - your device doesn't support the crop action!";
    Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
    toast.show();
    }


    }
    }

    Hallo, bitteum eine Hilfe !


    mein code funktioniert unter android 4 bis 6
    Nachdem ich my galaxy s6 auf Android 7.0 aktualisiert have, funktioniert my code nicht mehr



    private void Capture_Cam() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(intent, 113);


    }
    - - -


    } else if (requestCode == 113) {
    if (resultCode == RESULT_OK) { // from camera
    picUri = data.getData();
    try {
    bitmap2 = MediaStore.Images.Media.getBitmap(this.getContentResolver(), picUri); // Error hier bei dieser Linie
    bitmap_width_org = bitmap2.getWidth();
    bitmap_height_org = bitmap2.getHeight();
    } catch (IOException e) {
    e.printStackTrace();
    }
    performCrop();
    }
    } else if (requestCode == PIC_CROP) {
    - - -



    Fehler lautet :
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=113, result=-1, data=Intent { act=inline-data flg=0x1 launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }} to activity {---.Activity2}: java.lang.NullPointerException: uri