HI developers,
sorry for my bad English. I'm German.
i want to save the full-size image of the Camera into a file but my algorithm doesn't create the file. I read many tutorials about saving full-size photo and also threads with similar problems but they didn't work.
Here is my code. Does anyone know where's the problem?
After the file is saved on the internal storage it's copied into the server (XAMPP). When I create the file only with the thumbnail data it works.
Code:
private void makePhotoClick() {
try {
photoFile = new File(getFilesDir(), "test.jpg");
imageURI = Uri.fromFile(photoFile);
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageURI);
startActivityForResult(takePictureIntent, 1);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == 1 && resultCode == RESULT_OK) {
//Intent i=new Intent(Intent.ACTION_VIEW);
BitmapFactory.decodeFile(photoFile.getAbsolutePath()); // it also returns null
}
}
Print 'photoFile.getAbsolutePath()' on logcat console. Open Android Device Monitor (Tools -> Android -> Android Device Monitor) and check if file was created.
You can check also if file was created programmatically:
Code:
photoFile.exists()
Related
Well... I am trying to create an application using the TTS Engine.
I can already make it, work, no problem. However I need my buttons to be dinamic, they will come from a database.
**So far you guys have helped me a lot, since now I can do it thanks to the tips I got from you guys.**
**Well.. now I am stuck again.**
Every new button that I create I attach an OnClickListener so it can start the TTS and speak something.
However it's an inner method, so, when I try to run the code below, it gives me a NullPointerException when it tries to "speak" using the TTS. I know the TTS object is out of context, so, **How can I solve this?**
Below the code. It's a little big since I wanted to include everything:
PLEASE JUMP TO THE "HERE IS MY PROBLEM!!!" comment so you guys can see exactly where my problem is. I know where it is, but I don't know how to solve it =(
Any help is appreciatted! =)
Code:
public class LivoxTesteActivity extends Activity implements OnInitListener{
/** Called when the activity is first created. */
private int MY_DATA_CHECK_CODE = 0;
public TextToSpeech tts;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
LinearLayout lgeral = new LinearLayout (this);
lgeral.setOrientation(LinearLayout.VERTICAL);
lgeral.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f));
String array[][] = {{"Comer","eat", "Eu quero comer", "1"},
{"Abraço","hug", "Eu quero um abraço", "2"},
{"Assustado","afraid", "Eu estou com medo", "3"},
{"Beber","drink", "Eu quero beber", "4"}};
int x = array.length;
int qtdeLinhas = 2;
for (int j = 0; j < qtdeLinhas; j++) {
LinearLayout l1 = new LinearLayout (this);
l1.setOrientation(LinearLayout.HORIZONTAL);
l1.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f));
FrameLayout fl;
for (int i = 0; i < array.length; i++) {
fl = (FrameLayout)LayoutInflater.from(getBaseContext()).inflate(R.layout.framelayoutstyle, l1, false);
TextView textoEscrito;
textoEscrito = (TextView)LayoutInflater.from(getBaseContext()).inflate(R.layout.textviewstyle, fl, false);
textoEscrito.setText(array[i][0]);
final String texto = textoEscrito.getText().toString();
final String textoFalar = array[i][2];
ImageButton btn;
btn = (ImageButton)LayoutInflater.from(getBaseContext()).inflate(R.layout.imagebuttonstyle, fl, false);
btn.setImageResource(this.getResources().getIdentifier("drawable/" + array[i][1], null, this.getPackageName()));
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick (View v){
Toast.makeText(getBaseContext(), texto, Toast.LENGTH_SHORT).show();
//*******************************
//HERE IS MY PROBLEM!!!
//*******************************
tts.speak(txtFl, TextToSpeech.QUEUE_ADD, null);
//*******************************
//WHEN I TRY TO RUN THE ABOVE IT GIVES A NULLPOINTEREXCEPTION!!!
//*******************************
}
});
fl.addView(btn);
fl.addView(textoEscrito);
l1.addView(fl);
}
lgeral.addView(l1);
}
setContentView(lgeral);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MY_DATA_CHECK_CODE) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
// success, create the TTS instance
tts = new TextToSpeech(this, this);
}
else {
// missing data, install it
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
}
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
}
else if (status == TextToSpeech.ERROR) {
}
}
@Override
public void onDestroy() {
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
}
By the way... the method Toast.makeText(getBaseContext(), texto, Toast.LENGTH_SHORT).show(); works fine. I believe that's because the Toast is a static class.
So, maybe the solution is to create a static class with the method to speak? Ideas? How can I do it?
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A
Does anyone know which jar files and smali files/codes( lines) for adding music control and long press back button to kill apps ?
I need name of files and smali codes.
I need it, too
i think its android-policy.jar or services.jar maybe.
i need it too
AW: (REQ) How to Add Kill Long Press Kill Apps+ Long press volume keys to skip tracks
me too
This is what would be added for Settings:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
Code:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
public class DevelopmentSettings extends PreferenceActivity
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back";
private CheckBoxPreference mKillAppLongpressBack;
addPreferencesFromResource(R.xml.development_prefs);
mKillAppLongpressBack = (CheckBoxPreference) findPreference(KILL_APP_LONGPRESS_BACK);
}
@Override
protected void onResume() {
super.onResume();
mKillAppLongpressBack.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) != 0);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
} else if (preference == mKillAppLongpressBack) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK,
mKillAppLongpressBack.isChecked() ? 1 : 0);
}
And for frameworks:
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Code:
Runnable mBackLongPress = new Runnable() {
public void run() {
if (Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 0) {
return;
}
try {
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
IActivityManager mgr = ActivityManagerNative.getDefault();
List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses();
for (RunningAppProcessInfo appInfo : apps) {
int uid = appInfo.uid;
// Make sure it's a foreground USER application
if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID
&& appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// Kill the entire pid
Toast.makeText(mContext, com.android.internal.R.string.app_killed_message, Toast.LENGTH_SHORT).show();
Process.killProcess(appInfo.pid);
break;
}
}
I SAW IT FROM SAMSUNG PHONE, NOT SURE ABOUT OUR SONY
TELL ME IF IT WORKS
TeamIndia said:
This is what would be added for Settings:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
Code:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
public class DevelopmentSettings extends PreferenceActivity
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back";
private CheckBoxPreference mKillAppLongpressBack;
addPreferencesFromResource(R.xml.development_prefs);
mKillAppLongpressBack = (CheckBoxPreference) findPreference(KILL_APP_LONGPRESS_BACK);
}
@Override
protected void onResume() {
super.onResume();
mKillAppLongpressBack.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) != 0);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
} else if (preference == mKillAppLongpressBack) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK,
mKillAppLongpressBack.isChecked() ? 1 : 0);
}
And for frameworks:
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Code:
Runnable mBackLongPress = new Runnable() {
public void run() {
if (Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 0) {
return;
}
try {
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
IActivityManager mgr = ActivityManagerNative.getDefault();
List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses();
for (RunningAppProcessInfo appInfo : apps) {
int uid = appInfo.uid;
// Make sure it's a foreground USER application
if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID
&& appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// Kill the entire pid
Toast.makeText(mContext, com.android.internal.R.string.app_killed_message, Toast.LENGTH_SHORT).show();
Process.killProcess(appInfo.pid);
break;
}
}
I SAW IT FROM SAMSUNG PHONE, NOT SURE ABOUT OUR SONY
TELL ME IF IT WORKS
Click to expand...
Click to collapse
no its completely different...bcz we dont u use kill concept smali...
so we have to mod android.policy.jar
settings.apk
and fw-res.apk..
iam almost making a tut for it...will add it in my tut thread soon..
Hello guys, I'd like to ask you for your wisdom and maybe a little help.
After using an application that writes to SD card, my I9100 was bricked. It won't turn on, won't react to power button or any combination (recovery/download mode). When I plug the power, nothing comes up on the screen. I tried jump-starting it and other tricks with the exception of USB jig. The phone is just dead and nothing comes up on screen.
Below I paste a code of the ran application. It writes an image to SD card. The program ran without any problems, but the image was not written. I suppose the dd program somehow wrote to the wrong section and thus bricked the phone. Could someone confirm?
The path to the SD Card was /dev/block/mmcblk0
After the reboot, the phone just went stone cold dead.
Code:
protected void writeImage()
{
// Verify that root access is obtainable
if (!execCommandAsRoot("true")) {
showMessage("Your device is not rooted. Cannot proceed.");
return;
}
// Verify that SD card device exists
File sdDevice = new File(editOutputDevice.getText().toString());
if (!sdDevice.exists()) {
showMessage("SD card device does not exist, or no card inserted");
return;
}
// Progress dialog
final Handler progressHandler = new Handler();
final ProgressDialog progress = new ProgressDialog(this);
progress.setCancelable(false);
progress.setMessage("Starting thread");
progress.show();
// Write image in worker thread
new Thread(new Runnable() {
public void run() {
String imagefile = editImageFile.getText().toString();
String sd = editOutputDevice.getText().toString();
String datadir = getFilesDir().getPath();
/* The image files need to be extracted from the .apk to the data folder
* unless the user has run the app before, and this has already been done.
* We store the version (lastUpdate timestamp) of the extracted files in the preferences.
*/
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
long berrybootVersion = -1;
try {
berrybootVersion = getPackageManager().getPackageInfo(getPackageName(), 0).lastUpdateTime;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if (!new File(datadir+"/a10-patchspl").exists()
|| preferences.getLong("berrybootimgversion", 0) != berrybootVersion)
{
updateProgress("Uncompressing files from .apk");
try {
uncompressFile("berryboot.img", datadir);
uncompressFile("sunxi-spl.bin", datadir);
uncompressFile("a10-patchspl", datadir);
new File(datadir+"/a10-patchspl").setExecutable(true);
new File(datadir+"/mntNand").mkdir();
new File(datadir+"/mntSD").mkdir();
preferences.edit().putLong("berrybootimgversion", berrybootVersion).commit();
} catch (IOException ie) {
error("Error uncompressing files. Check disk space.");
return;
}
}
updateProgress("Unmounting SD card");
execCommandAsRoot("umount "+sd);
execCommandAsRoot("umount "+sd+"p1");
/* Also unmount everything mounted to /mnt/extSdCard,
* as vold seems to mount /dev/vold/somedevice instead of /dev/block/mmcblk0p1 */
String[] extsdFolders = new File("/mnt/extSdCard").list();
for (String extsdFolder : extsdFolders)
{
execCommandAsRoot("umount /mnt/extSdCard/"+extsdFolder);
}
execCommandAsRoot("umount /mnt/extSdCard");
updateProgress("Writing image to SD card");
if (!execCommandAsRoot("dd 'if="+imagefile+"' of="+sd+" bs=1024k"))
{
error("Error writing image file to SD card");
return;
}
if (checkPatch.isChecked())
{
updateProgress("Patching u-boot SPL");
if (!execCommandAsRoot(datadir+"/a10-patchspl "+datadir+"/sunxi-spl.bin "+sd))
{
error("Error patching u-boot SPL");
return;
}
updateProgress("Copying script.bin from NAND to SD");
if (!execCommandAsRoot("mount -t vfat /dev/block/nanda "+datadir+"/mntNand"))
{
error("Error mounting /dev/block/nanda");
return;
}
if (!execCommandAsRoot("mount -t vfat "+sd+"p1 "+datadir+"/mntSD"))
{
error("Error mounting SD card device");
return;
}
String scriptbin;
if ( new File(datadir+"/mntNand/script.bin").exists() )
scriptbin = datadir+"/mntNand/script.bin";
else if ( new File(datadir+"/mntNand/evb.bin").exists() )
scriptbin = datadir+"/mntNand/evb.bin";
else
{
error("Neither script.bin nor evb.bin exists in NAND");
return;
}
if (!execCommandAsRoot("cat "+scriptbin+ " >"+datadir+"/mntSD/script.bin"))
{
error("Error copying "+scriptbin+" to SD");
return;
}
/* Save human readable a10-memdump info to a10-meminfo.txt on the SD card for debugging purposes */
execCommandAsRoot(datadir+"/a10-patchspl -dump > "+datadir+"/mntSD/a10-meminfo.txt");
if (!execCommandAsRoot("umount "+datadir+"/mntNand"))
{
error("Error unmounting /dev/block/nanda");
return;
}
if (!execCommandAsRoot("umount "+datadir+"/mntSD"))
{
error("Error unmounting SD card device");
return;
}
}
updateProgress("Finish writing... (sync)");
execCommandAsRoot("sync");
finished();
}
// Update the progress in the UI thread
protected void updateProgress(final String msg)
{
progressHandler.post(new Runnable() {
@Override
public void run() {
progress.setMessage(msg);
}
});
}
// Show error in UI thread
protected void error(final String msg)
{
progressHandler.post(new Runnable() {
@Override
public void run() {
progress.hide();
showMessage(msg);
}
});
}
// Notify UI thread we are finished
protected void finished() {
progressHandler.post(new Runnable() {
@Override
public void run() {
progress.hide();
askReboot();
}
});
}
/*
* Uncompress utility file stored in .apk to datadir
*/
protected void uncompressFile(String filename, String dest) throws IOException
{
InputStream is = getAssets().open(filename);
OutputStream os = new FileOutputStream(dest+"/"+filename);
byte[] buf = new byte[4096];
int len;
while ((len =is.read(buf)) > 0) {
os.write(buf, 0, len);
}
os.close();
is.close();
}
}).start(); // start thread
}
protected void showMessage(String msg)
{
new AlertDialog.Builder(this)
.setMessage(msg)
.setNeutralButton("Ok", null)
.create().show();
}
protected void askReboot()
{
/* Ask if user wants to reboot */
new AlertDialog.Builder(this)
.setMessage("All done! Reboot now?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
execCommandAsRoot("reboot");
}
})
.setNegativeButton("No", null)
.create().show();
}
protected boolean execCommandAsRoot(String path)
{
try {
String[] cmd = {"su","-c",path};
Process p = Runtime.getRuntime().exec(cmd);
int exitCode = p.waitFor();
return (exitCode == 0);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
If absolutely nothing comes on with the charger or even the power button your phone may truly be bricked. Are you sure you have tried everything? There may be hope yet.
Perhaps the only way is via the USB jig. Try that.
Sent from my ONE TOUCH 4033A using Tapatalk
Service centre = motherboard replacement. Try a jig, but very very unlikely to work.
Vexi said:
Hello guys, I'd like to ask you for your wisdom and maybe a little help.
After using an application that writes to SD card, my I9100 was bricked. It won't turn on, won't react to power button or any combination (recovery/download mode). When I plug the power, nothing comes up on the screen. I tried jump-starting it and other tricks with the exception of USB jig. The phone is just dead and nothing comes up on screen.
Below I paste a code of the ran application. It writes an image to SD card. The program ran without any problems, but the image was not written. I suppose the dd program somehow wrote to the wrong section and thus bricked the phone. Could someone confirm?
The path to the SD Card was /dev/block/mmcblk0
After the reboot, the phone just went stone cold dead.
Code:
protected void writeImage()
{
// Verify that root access is obtainable
if (!execCommandAsRoot("true")) {
showMessage("Your device is not rooted. Cannot proceed.");
return;
}
// Verify that SD card device exists
File sdDevice = new File(editOutputDevice.getText().toString());
if (!sdDevice.exists()) {
showMessage("SD card device does not exist, or no card inserted");
return;
}
// Progress dialog
final Handler progressHandler = new Handler();
final ProgressDialog progress = new ProgressDialog(this);
progress.setCancelable(false);
progress.setMessage("Starting thread");
progress.show();
// Write image in worker thread
new Thread(new Runnable() {
public void run() {
String imagefile = editImageFile.getText().toString();
String sd = editOutputDevice.getText().toString();
String datadir = getFilesDir().getPath();
/* The image files need to be extracted from the .apk to the data folder
* unless the user has run the app before, and this has already been done.
* We store the version (lastUpdate timestamp) of the extracted files in the preferences.
*/
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
long berrybootVersion = -1;
try {
berrybootVersion = getPackageManager().getPackageInfo(getPackageName(), 0).lastUpdateTime;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if (!new File(datadir+"/a10-patchspl").exists()
|| preferences.getLong("berrybootimgversion", 0) != berrybootVersion)
{
updateProgress("Uncompressing files from .apk");
try {
uncompressFile("berryboot.img", datadir);
uncompressFile("sunxi-spl.bin", datadir);
uncompressFile("a10-patchspl", datadir);
new File(datadir+"/a10-patchspl").setExecutable(true);
new File(datadir+"/mntNand").mkdir();
new File(datadir+"/mntSD").mkdir();
preferences.edit().putLong("berrybootimgversion", berrybootVersion).commit();
} catch (IOException ie) {
error("Error uncompressing files. Check disk space.");
return;
}
}
updateProgress("Unmounting SD card");
execCommandAsRoot("umount "+sd);
execCommandAsRoot("umount "+sd+"p1");
/* Also unmount everything mounted to /mnt/extSdCard,
* as vold seems to mount /dev/vold/somedevice instead of /dev/block/mmcblk0p1 */
String[] extsdFolders = new File("/mnt/extSdCard").list();
for (String extsdFolder : extsdFolders)
{
execCommandAsRoot("umount /mnt/extSdCard/"+extsdFolder);
}
execCommandAsRoot("umount /mnt/extSdCard");
updateProgress("Writing image to SD card");
if (!execCommandAsRoot("dd 'if="+imagefile+"' of="+sd+" bs=1024k"))
{
error("Error writing image file to SD card");
return;
}
if (checkPatch.isChecked())
{
updateProgress("Patching u-boot SPL");
if (!execCommandAsRoot(datadir+"/a10-patchspl "+datadir+"/sunxi-spl.bin "+sd))
{
error("Error patching u-boot SPL");
return;
}
updateProgress("Copying script.bin from NAND to SD");
if (!execCommandAsRoot("mount -t vfat /dev/block/nanda "+datadir+"/mntNand"))
{
error("Error mounting /dev/block/nanda");
return;
}
if (!execCommandAsRoot("mount -t vfat "+sd+"p1 "+datadir+"/mntSD"))
{
error("Error mounting SD card device");
return;
}
String scriptbin;
if ( new File(datadir+"/mntNand/script.bin").exists() )
scriptbin = datadir+"/mntNand/script.bin";
else if ( new File(datadir+"/mntNand/evb.bin").exists() )
scriptbin = datadir+"/mntNand/evb.bin";
else
{
error("Neither script.bin nor evb.bin exists in NAND");
return;
}
if (!execCommandAsRoot("cat "+scriptbin+ " >"+datadir+"/mntSD/script.bin"))
{
error("Error copying "+scriptbin+" to SD");
return;
}
/* Save human readable a10-memdump info to a10-meminfo.txt on the SD card for debugging purposes */
execCommandAsRoot(datadir+"/a10-patchspl -dump > "+datadir+"/mntSD/a10-meminfo.txt");
if (!execCommandAsRoot("umount "+datadir+"/mntNand"))
{
error("Error unmounting /dev/block/nanda");
return;
}
if (!execCommandAsRoot("umount "+datadir+"/mntSD"))
{
error("Error unmounting SD card device");
return;
}
}
updateProgress("Finish writing... (sync)");
execCommandAsRoot("sync");
finished();
}
// Update the progress in the UI thread
protected void updateProgress(final String msg)
{
progressHandler.post(new Runnable() {
@Override
public void run() {
progress.setMessage(msg);
}
});
}
// Show error in UI thread
protected void error(final String msg)
{
progressHandler.post(new Runnable() {
@Override
public void run() {
progress.hide();
showMessage(msg);
}
});
}
// Notify UI thread we are finished
protected void finished() {
progressHandler.post(new Runnable() {
@Override
public void run() {
progress.hide();
askReboot();
}
});
}
/*
* Uncompress utility file stored in .apk to datadir
*/
protected void uncompressFile(String filename, String dest) throws IOException
{
InputStream is = getAssets().open(filename);
OutputStream os = new FileOutputStream(dest+"/"+filename);
byte[] buf = new byte[4096];
int len;
while ((len =is.read(buf)) > 0) {
os.write(buf, 0, len);
}
os.close();
is.close();
}
}).start(); // start thread
}
protected void showMessage(String msg)
{
new AlertDialog.Builder(this)
.setMessage(msg)
.setNeutralButton("Ok", null)
.create().show();
}
protected void askReboot()
{
/* Ask if user wants to reboot */
new AlertDialog.Builder(this)
.setMessage("All done! Reboot now?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
execCommandAsRoot("reboot");
}
})
.setNegativeButton("No", null)
.create().show();
}
protected boolean execCommandAsRoot(String path)
{
try {
String[] cmd = {"su","-c",path};
Process p = Runtime.getRuntime().exec(cmd);
int exitCode = p.waitFor();
return (exitCode == 0);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
Click to expand...
Click to collapse
Take your phone to local repair mobile shop.... and asks for POWER IC replacement( if there is problem in it.. ask him to check for it)
or motherboard replacement..
If your finally decision is motherboard replacement.. then in mean time do this on your motherboard may be it'll work :
check out this link-
http://forum.gsmhosting.com/vbb/f258/samsung-galaxy-s2-i9100-short-circuit-solution-1537757/
If your hand are handy to these things you can do it yourself otherwise Ask an technician to do this...
And
Let us know what will happen
Do you think JTAG / RIFF Box will help anything in this situation?
Vexi said:
Do you think JTAG / RIFF Box will help anything in this situation?
Click to expand...
Click to collapse
It doesn't guarantee your phone will be repaired or not.. BUT yes you can give it a chance...
Very very unlikely to work. Don't go out and buy one, put it that way.
So i need to read a file from a URI and copy it into the internal storage. My function to write to external storage works fine but writing to internal storage has proven to be a difficult task. Nothing i do seems to work. Here's my code below. It doesn't throw any errors but it doesn't write anything.
Code:
public Uri selectedfile;
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//this.onActivityResult(requestCode, resultCode, data);
if(requestCode==123 && resultCode==RESULT_OK) {
selectedfile = data.getData();
try {
InputStream in = getContentResolver().openInputStream(selectedfile);
FileOutputStream out = this.openFileOutput("myFile.txt", Context.MODE_PRIVATE);
out.write(in.toString().getBytes());
out.flush();
out.close();
in.close();
doToast("Success?");
} catch (IOException e) {
doToast(e.getMessage());
}
}
}
I have created an app which shares an audio file to whatsapp when a user holds down a button. All works well, except for the fact that I can no longer share audio files directly from Whatsapp. This behaviour is illustrated below. Audio can be shared by clicking on 'Audio' which should redirect the user to a file like activity where they can select their audio. See ibb (dot) co/WDwfSGq for screenshot (since I can't link images yet *sigh*).
This is, however, not the case. When I click it, WhatsApp redirects me to the audio recorder. From this screen I can record some audio and share that audio, but I cannot browse my files. See ibb (dot) co/12hg1SQ
I suspect the intent defined below has caused this as other users have reported the same issue while others, who did not use this functionality yet, have no problem when sharing audio directly via WhatsApp.
Code:
public boolean onLongClick(View view) {
String permission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
if (ContextCompat.checkSelfPermission(mContext, permission) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((MainActivity) mContext, new String[]{permission}, 2);
return false;
} else {
// Permission has been granted
try {
String file = "soundboard/" + person + "/" + getItem(getAdapterPosition());
file = copyFiletoExternalStorage(file, getItem(getAdapterPosition()));
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file));
sendIntent.setType("audio/*");
mContext.startActivity(Intent.createChooser(sendIntent, "Send your audio file"));
return true;
} catch (Exception e) {
Toast.makeText(mContext.getApplicationContext(), "Sharing has failed.", Toast.LENGTH_SHORT).show();
return false;
}
}
}
And a helper class to copy the file to sd storage prior to sending the intent. This code has been taken and modified from this comment on stackoverflow: stackoverflow (dot) com/a/46243768/11086911
Code:
private String copyFiletoExternalStorage(String file, String resourceName){
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
String pathSDCard = Environment.getExternalStorageDirectory() + "/Android/data/" + mContext.getPackageName() + "/" + resourceName;
try {
InputStream in = mContext.getAssets().open(file);
FileOutputStream out;
out = new FileOutputStream(pathSDCard);
byte[] buff = new byte[1024];
int read;
try {
while ((read = in.read(buff)) > 0) {
out.write(buff, 0, read);
}
out.flush();
} finally {
in.close();
out.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return pathSDCard;
}
else
return "";
}
I have already deinstalled my own application, rebooted my phone, and reinstalled WhatsApp but to no avail. What can I do to fix WhatsApp and how do I prevent this from happening again? For reference, I am running a Huawei P10 lite with stock rom Android 8.0 and have made no modifications at all. Though as I said before, this issue has been reported on other phones as well.