Przesylam kod. Nieznacznie go przerobilem, ale sens pozostal.
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data)
{
if (requestCode==2)
{
usun_plik(zdjecie_plik_do_usuniecia);
}
if (requestCode==1 && resultCode==RESULT_OK) //&& data!=null)
{
//Bitmap zdjecie=(Bitmap) data.getExtras().get("data");
Bitmap bitmap=null;
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFile(plik_nazwa_file.toString(),bmpFactoryOptions);
SharedPreferences preferences_odczyt = getSharedPreferences("kluczyk",MODE_PRIVATE);
Boolean delete_check=preferences_odczyt.getBoolean("check_delete_name", false);
if (!delete_check)
{
Toast.makeText(getApplicationContext(), getString(R.string.komunikat_zapisu_zdjecia),Toast.LENGTH_LONG).show();
}
ImageView iv_zdjecie=(ImageView)findViewById(R.id.imageView1);
iv_zdjecie.setImageBitmap(bitmap);
Thread thread = new Thread(new Runnable(){
@Override
public void run()
{
try {
String p_to="";
String p_to_cc="";
String p_subject="";
String p_msg="";
String to_name = "";
String cc_name = "";
Boolean polska_check=false;
Boolean delete_check=false;
try
{
SharedPreferences preferences_odczyt = getSharedPreferences("kluczyk",MODE_PRIVATE);
to_name = preferences_odczyt.getString("name", null);
cc_name = preferences_odczyt.getString("cc_name", null);
polska_check=preferences_odczyt.getBoolean("check_name", false);
delete_check=preferences_odczyt.getBoolean("check_delete_name", false);
}
catch (Exception e)
{
e.printStackTrace();
}
if (to_name != null)
{
p_to =to_name;
}
if (cc_name!=null)
{
p_to_cc = cc_name;
}
String p_msg1="";
p_msg1="Kopie pliku zapisano na tablecie/smartfonie w ścieżce: /DCIM/CAMERA/.\n";
p_subject = "Temacik";
p_msg ="Witam!\n\nTo zdjęcie wykonałeś o godzinie: "+currentDateAndTime_txt+".\nNazwa pliku: "+plik_nazwa+".\n"+p_msg1;
Intent email = new Intent(Intent.ACTION_SEND);
email .setType("image/jpeg");
email .putExtra(Intent.EXTRA_SUBJECT, p_subject);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ p_to});
if (p_to_cc!="")
{
email.putExtra(Intent.EXTRA_CC, new String[]{ p_to_cc});
}
email.putExtra(Intent.EXTRA_SUBJECT, p_subject);
email.putExtra(Intent.EXTRA_TEXT, p_msg);
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(plik_nazwa_file));
startActivityForResult(Intent.createChooser(email , "Email:"),2);
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
//finish();
}
}
---------- Post dołączono o 21:08 ---------- Poprzedni post napisano o 19:58 ----------
W deklaracji public glownej classy mam taki oto kod
public String plik_nazwa=currentDateAndTime+"_foteczka.jpg";
File plik_nazwa_file=new File(Environment.getExternalStorageDirectory()+"/DCIM/CAMERA/", plik_nazwa);
.....
email.putExtra(Intent.EXTRA_SUBJECT, p_subject);
email.putExtra(Intent.EXTRA_TEXT, p_msg);
Uri contentUri = getUriForFile(getContext(),"pl.aplikacjanazwa.fileprovider", plik_nazwa_file);
email.putExtra(Intent.EXTRA_STREAM,contentUri);
startActivityForResult(Intent.createChooser(email , "Email:"),2);
otrzymuje taki blad:
The method getContext() is undefined for the type new Runnable(){} Aplikacja.java /AAA/src/pl/AAA/ZZZ line 503 Java Problem
Czy mozecie pomoc?
---------- Post dołączono 04-12-14 o 15:13 ---------- Poprzedni post napisano 03-12-14 o 21:08 ----------
Zastąpiłem getContext() -> this.
ale mam taki oto błąd:
The method getUriForFile(new Runnable(){}, String, File) is undefined for the type new Runnable(){}
Znalazłem taki podobny problem na stronie:
java - The method findViewById(int) is undefined for the type new Runnable(){} - Stack Overflow
ale nie bardzo wiem jak go przełożyć na mój kod.
Proszę o pomoc
Pozdrawiam