Hi every one
In WP8 we could use
Protected Override Void OnbackKeyPress(....e)
{
}
Now I didn't find such thing in windows Phone 8.1 ! Can anyone help me with this ?
and my other Q is : where is the messagebox.show ? and also Isolated Storage ?!
Now I think get an absolutely Noooob again
ngame said:
Hi every one
In WP8 we could use
Protected Override Void OnbackKeyPress(....e)
{
}
Now I didn't find such thing in windows Phone 8.1 ! Can anyone help me with this ?
and my other Q is : where is the messagebox.show ? and also Isolated Storage ?!
Now I think get an absolutely Noooob again
Click to expand...
Click to collapse
Hi,
instead of overriding OnbackKeyPress you have to register the event
...
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
...
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
// your code
e.Handled = true; // if you wanna prevent that the "standard"-eventhandler is called and your app getting closed
}
Best,
ElStoney said:
Hi,
instead of overriding OnbackKeyPress you have to register the event
...
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
...
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
// your code
e.Handled = true; // if you wanna prevent that the "standard"-eventhandler is called and your app getting closed
}
Best,
Click to expand...
Click to collapse
Thanks.
And what about isolated storage?
I can't use them any more and power tools ran out
Look for StorageFile and StorageFolder:
http://msdn.microsoft.com/de-de/library/windows/apps/windows.storage.aspx
And here is a Storage Helper class from Jerry Nixon that is useful: http://codepaste.net/gtu5mq
Related
edit: not much use in this thread anymore, except maybe a good reference for people making an app
How about rebooting the phone? Will that work?
well yeah, but i don't think people will pay for an app that reboots your phone each time you change the volume settings
I think its, Runtime.getRuntime.exec("your command");
have you seen this?
http://forum.xda-developers.com/showpost.php?p=3434331&postcount=35
hamshu said:
I think its, Runtime.getRuntime.exec("your command");
Click to expand...
Click to collapse
do you think you could elaborate a little more?
i'm still a complete java noob
Process process = Runtime.getRuntime().exec("killall mediaserver");
That line should do it.
hamshu said:
Process process = Runtime.getRuntime().exec("killall mediaserver");
That line should do it.
Click to expand...
Click to collapse
i've got:
try {
Process process = Runtime.getRuntime().exec("killall mediaserver");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and it doesn't seem to do anything.
any ideas?
try {
Process process = Runtime.getRuntime().exec("sh");
DataOutputStream out = new DataOutputStream(process.getOutputStream());
out.writeBytes("killall mediaserver\n");
out.writeBytes("exit\n");
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
try this, see what it does man
or try this:
Code:
try {
Class<?> execClass = Class.forName("android.os.Exec");
Method createSubprocess = execClass.getMethod("createSubprocess",
String.class, String.class, String.class, int[].class);
Method waitFor = execClass.getMethod("waitFor", int.class);
int[] pid = new int[1];
FileDescriptor fd = (FileDescriptor)createSubprocess.invoke(
null, "/system/xbin/bb/killall", "mediaserver", null, pid);
FileInputStream in = new FileInputStream(fd);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String output = "";
try {
String line;
while ((line = reader.readLine()) != null) {
output += line + "\n";
}
} catch (IOException e) {
}
waitFor.invoke(null, pid[0]);
return output;
} catch (ClassNotFoundException e) {
throw new RuntimeException(e.getMessage());
} catch (SecurityException e) {
throw new RuntimeException(e.getMessage());
} catch (NoSuchMethodException e) {
throw new RuntimeException(e.getMessage());
} catch (IllegalArgumentException e) {
throw new RuntimeException(e.getMessage());
} catch (IllegalAccessException e) {
throw new RuntimeException(e.getMessage());
} catch (InvocationTargetException e) {
throw new RuntimeException(e.getMessage());
}
the last bit of code i posted dude i know works with an ls command, but with this, we are trying to spawn killall and pass the mediaserver argument, so i dont know if the stack will even handle this.... doesnt hurt to try though
corp769 said:
the last bit of code i posted dude i know works with an ls command, but with this, we are trying to spawn killall and pass the mediaserver argument, so i dont know if the stack will even handle this.... doesnt hurt to try though
Click to expand...
Click to collapse
From the little I know about Android Development, I think that it will work. Then again, I am not a Java coder nor a Android Developer(C# coding ftw). Sorry about getting the Java code wrong, like I stated, I don't code any Java.
It's cool...meltus, how's it going? You have a pm btw...
sorry guys, not had any success yet, but my girlfriends come round so i'll be away for a while
I suppose you need superuser privileges to kill the mediaserver.
This might work :
Process process = Runtime.getRuntime().exec("su -c \"killall mediaserver\"");
Meltus said:
sorry guys, not had any success yet, but my girlfriends come round so i'll be away for a while
Click to expand...
Click to collapse
Pervert lol JK
Zappletoo said:
I suppose you need superuser privileges to kill the mediaserver.
This might work :
Process process = Runtime.getRuntime().exec("su -c \"killall mediaserver\"");
Click to expand...
Click to collapse
this kinda works. i get a SU permission request, but it doesn't reboot the mediaserver. any ideas? ><
alritewhadeva said:
Pervert lol JK
Click to expand...
Click to collapse
lies
goddammit i hate this damn app lol ><
now i've run across another problem, which is, i just realised the system needs to be in read/write mode (im an idiot).
so:
Code:
try {
Process process = Runtime.getRuntime().exec("su");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
works fine. makes an SU request popup thing appear, but...
Code:
try {
Process process = Runtime.getRuntime().exec("mount -o rw,remount /dev/block/mtdblock3 /system");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
afterwards doesn't do anything. anyone know why this isn't working?
damn, i hate java lol
EDIT: I've also realised that
Code:
(Process process = Runtime.getRuntime().exec("su");
works fine but replacing it with
Code:
(Process process = Runtime.getRuntime().exec("reboot");
does nothing?!? wtf's going on!! lol
ONLY su works. no other commands seem to do anything
I'm not a coder by any means (more like a beta tester, but I can go through a code and 'see' it pretty easily) and I've often refered to this specific code for sms backup for root user app to do basic things..it basically uses two buttons and sends commands to the system. Check out the source code to see if it helps any: http://code.google.com/p/sms-backup-root/
Specifically the event when a button is pressed (notice it gets 'su' the same way you currently do, but does the actual commands differently):
Code:
backup.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Process process = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
[B]os.writeBytes("cp /data/data/com.android.providers.telephony/databases/mmssms.db /sdcard \n");[/B]
[B]os.writeBytes("exit\n");[/B]
os.flush();
process.waitFor();
builder.setMessage("Backup done.. Found it in /sdcard/mmssms.db");
builder.show();
} catch (Exception e) {
return;
}
finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
// Be Happy :)
}
}
return;
} });
It uses writebytes to send the code to the os. Try your code around that template and it may give you what you want.
Again im no coder, but there are a lot of open source apps that can give you a start towards what you want to do. Hope that helps!
p.s. love the audio mods, keep up the great work! Let me know if you want graphic work :]
Here you go.
Runtime rt = Runtime.getRuntime();
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("reboot");
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
I just ran this on my phone and it rebooted.... Once you start the process, you use .writeBytes to "type to it". As if you were at the terminal and just typed "su"...
Instead of "reboot", you could do "killall mediaserver" or anything else you want to type to the console...
Hi, how would u go about incoporating file commands such as delete into and android app in eclipse which i am using ?
Thanks
For manipulating files, you should look at java.io.File
i.e.
File file = new File("path");
file.delete();
Hey, thanks for that i tried it..it works for files but for deleting folders that are not empty it doesnt work ? ne way to work around that ?
Thanks Again For Your Quick Reply
I used this in my Audio Hack app and it worked nicely
Code:
Process process = null;
try {
process = Runtime.getRuntime().exec("su");
} catch (IOException e1) {
e1.printStackTrace();
}
DataOutputStream os = new DataOutputStream(process.getOutputStream());
try {
os.writeBytes("busybox rm -r blah/blah/blah \n");
} catch (IOException e) {
e.printStackTrace();
}
try {
os.writeBytes("exit\n");
} catch (IOException e) {
e.printStackTrace();
}
try {
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
this just runs any busybox command as root so you can do whatever you want.
it seems to only work for me with busybox at the start though, meaning anyone using it must have busybox.
hope this answers your question
Hmmm....nice script u have there...so im tryin to make a script for my app where it would go into a directory..get the filenames....n substitute that into the filename.delete() command....can neone help ?
Also on most command prompt/shells....when u do delete folder/*.* it deletes everything in tht folder...no substitute for android ?
You need to use caution when using that approach since;
1) it requires root (at least his example does),
*2*) it is dependent on what commands are available on the particular system. You can't rely on anything here.
The workaround for deleting non-empty directories is to first delete the contents in order to MAKE them empty.
It is fairly simple to write a recursive delete function;
void recursiveDelete(String path){
File file = new File(path);
if (!file.delete() && file.isDirectory()){
String[] filelist = file.list();
for (int i=0; i<filelist.length; i++) recursiveDelete(filelist);
file.delete();
}
}
I don't know what the paths that are returned by file.list() look like... there is another function "isAbsolute()" to check if it is a relative or absolute path returned... if it is a relative path, then you want to do your recursiveDelete on path+"/"+filelist.
Note: you could also take this approach, which is probably a little more clean;
void recursiveDelete(File file){
if (!file.delete() && file.isDirectory()){
File[] filelist = file.listFiles();
for (int i=0; i<filelist.length; i++) recursiveDelete(filelist);
file.delete();
}
}
This approach solves the whole absolute/relative path question. You just have to remember to
recursiveDelete(new File("path"));
Instead of:
recursiveDelete("path");
Daneshm90 said:
Hmmm....nice script u have there...so im tryin to make a script for my app where it would go into a directory..get the filenames....n substitute that into the filename.delete() command....can neone help ?
Also on most command prompt/shells....when u do delete folder/*.* it deletes everything in tht folder...no substitute for android ?
Click to expand...
Click to collapse
Actually, what he is doing is not at all scripted... he is running a SHELL COMMAND.
to the point How to findAndHookMethod this method:
Code:
public static ujiCoba(String[] string) {
}
i've tried with code bellow, but didnt work
Code:
findAndHookMethod(findClass, classLoader, String.class, hook);
You're not passing the method's name to findAndHookMethod. Also, the argument's class should be String[].class.
GermainZ said:
You're not passing the method's name to findAndHookMethod. Also, the argument's class should be String[].class.
Click to expand...
Click to collapse
i'm typo.
its work
hi @GermainZ. last qustion..
Code:
private static void getDetail(Context context, long l1, Info info, int i, long l2) {
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), Uri.parser(Prefs.PARSER), new String[] {"status","sent","date"}, "group_id=", l1, null, null);
}
method like that make me confuse. i want change sent to received, how can i do this?
riskey95 said:
hi @GermainZ. last qustion..
Code:
private static void getDetail(Context context, long l1, Info info, int i, long l2) {
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), Uri.parser(Prefs.PARSER), new String[] {"status","sent","date"}, "group_id=", l1, null, null);
}
method like that make me confuse. i want change sent to received, how can i do this?
Click to expand...
Click to collapse
You can replace the method and replicate these two lines, doing whatever modifications you want.
See:
XC_MethodReplacement to replace the method,
findClass to get the SqliteWrapper class,
callStaticMethod to call SqliteWrapper.query.
The rest should be covered in the development tutorial/wiki.
GermainZ said:
You can replace the method and replicate these two lines, doing whatever modifications you want.
See:
XC_MethodReplacement to replace the method,
findClass to get the SqliteWrapper class,
callStaticMethod to call SqliteWrapper.query.
The rest should be covered in the development tutorial/wiki.
Click to expand...
Click to collapse
that method very long and i dont have full of source code. so i can't replace method.
riskey95 said:
that method very long and i dont have full of source code. so i can't replace method.
Click to expand...
Click to collapse
Next best thing I can think of:
in beforeHookedMethod for getDetail, hook SqliteWrapper.query.
In that hook, check if the third argument is equal to the string array you want. If so, change it.
In afterHookedMethod for getDetail, unhook SqliteWrapper.query.
My code
Code:
XposedHelpers.findAndHookMethod("com.android.packageinstaller.InstallAppProgress$mHandler",
lpparam.classLoader, "handleMessage", Message.class, new XC_MethodHook(){
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {...
https://github.com/android/platform...roid/packageinstaller/InstallAppProgress.java
I want hook method "handleMessage". But it doesnt work. Method not found.
pyler said:
My code
Code:
XposedHelpers.findAndHookMethod("com.android.packageinstaller.InstallAppProgress$mHandler",
lpparam.classLoader, "handleMessage", Message.class, new XC_MethodHook(){
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {...
https://github.com/android/platform...roid/packageinstaller/InstallAppProgress.java
I want hook method "handleMessage". But it doesnt work. Method not found.
Click to expand...
Click to collapse
are you sure InstallAppProgress$mHandler was exist? i've try to decompile Packageinstaller.apk of my phone and InstallAppProgress$mHandler doesn't exist, method handleMessage on my phone belong to InstallAppProgress$1.class
riskey95 said:
are you sure InstallAppProgress$mHandler was exist? i've try to decompile Packageinstaller.apk of my phone and InstallAppProgress$mHandler doesn't exist, method handleMessage on my phone belong to InstallAppProgress$1.class
Click to expand...
Click to collapse
I tried to remove $mHandler but still it isnt working.
Maybe @GermainZ can help?
That's an anonymous class, it'll be called InstallAppProgress$number. "number" is a counter (starts at 1, ends at n, where n is the number if anonymous classes in the enclosing class) chosen by the compiler at compile time. It's not guaranteed to stay the same.
You can hook it as riskey95 said, but it might not be InstallAppProgress$1 everywhere (could be e.g. InstallAppProgress$2). TIAS, and maybe blindly try hooking $1 to $3 if necessary (use a try/catch statement).
$1 worked. Now I need to get access to mDoneButton. But I cant since I am in InstallAppDetails$1.
Code:
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {
//prefs.reload();
test = true;
if (test) {
Button mDone = (Button) XposedHelpers.getObjectField(
param.thisObject, "mDoneButton");
// todo
}
}
You can get the outer class using, for example:
Code:
XposedHelpers.getObjectField(param.thisObject, "this$0");
(There might be an Xposed helper or an alternate method to do that, I can't remember and I can't check right now.)
GermainZ said:
You can get the outer class using, for example:
Code:
XposedHelpers.getObjectField(param.thisObject, "this$0");
(There might be an Xposed helper or an alternate method to do that, I can't remember and I can't check right now.)
Click to expand...
Click to collapse
Fanstastic. All work now. I have to put your nick in XInstaller OP
Thank you.
p.s: found. getSurroundingThis
Hi,
can you please share the final code that worked for you in this case:
XposedHelpers.findAndHookMethod("com.android.packageinstaller.InstallAppProgress$mHandler",
lpparam.classLoader, "handleMessage", Message.class, new XC_MethodHook(){
@override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {...
Thanks!
I finding a correct way to start some app when started Android or restared
I have something like
Code:
public void startSomeApp() {
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("xxx.xxx.xxx");
if (launchIntent != null) {
context.startActivity(launchIntent);
}
}
But was wonder a correct way where should I put?
I try to push to
Code:
public void initZygote(StartupParam startupParam) throws Throwable {
startSomeApp();
}
But problem with context, any trick please?
1001z said:
I finding a correct way to start some app when started Android or restared
I have something like
But was wonder a correct way where should I put?
I try to push to
But problem with context, any trick please?
Click to expand...
Click to collapse
The correct way is without Xposed! Use the Android BOOT_COMPLETED broadcast.