I want to write an android APP which can run "getevent" command in a non-rooted device, and give out all the result when my finger draw on the device. after search, I found it need root permission, otherwise almost impossible to make it done.
It is true that in a non-rooted device, an app can not run a 'getevent'? or there is otherway around?
i found this link,
enter link description here
the author said he 'get it done', but the link he gave requires rooted device.
what can I do?
if I connect a PC to the android device with a USB line , I can use adb shell to run getevent. but this app has to be running starting from a Main() function
I failed when I change it to an android service . that means I cann't make it an auto-start up app to run 'getevent', can you help me to convert it a service, so it can auto start?
my Main() app (which works to run 'getevent')
public class Main {
public static void main(String[] args){
new ServiceThread(PORT).start(); // run getevent
while (true);
}
}
3 when done compiling the app as above question 2, how can I make it auto start and still have root permission. right now I use
adb push myapp.apk /device/path
and
adb shell app_process -Djava.class.path=myadd.apk mypack.Main
and it works. but it has to be connected to a pc.
how can i get rid of the USB line and still make it have root permission?
it baffles me quite awhile.
thank you very much.
Related
I am automating an android device, my target is to automate everything and keep physical maintenance to a minimum. I have two devices with USB debugging on but, when I turn the appium server on it starts running code on the wrong device.
Is there a way to programatically specify which device appium sends code to?
Or is there a way to disconnect a specific adb device through command prompt?
Any help would be greatly appreciated, this is the last step in finishing my project. Thank you in advance.
You can use the udid capability for that.
caps.setCapability("udid", "udidDevice");
You can find udidDevice using adb devices command on the terminal with both devices connected and get the one you are interested in.
I cannot seem to run this application which is supposedly ready to go to run on the Android Wear emulator.
Appreciate if someone can help me as to why this app does not actually get deployed to Watch emulator. I can see that the unaligned APK gets generated though.
I am following this guide:
http://toastdroid.com/2014/07/18/developing-watchfaces-for-android-wear/
Code is available at:
https://github.com/twotoasters/watchface-template
To install watchface you need to generate signed APK and push it to phone that is connected to that emulator, and install it there. After 1-2 minutes watchface should appear on the Wear device - if doesn't sync apps by companion app.
Also make sure that package for phone contains 'wear' part.
The key here is that you're using the emulator. If you run WatchfaceActivity.java from the Wear module on the emulator, you will see the watch appear on screen, but as an activity that can be dismissed.
If you then try to select it as the default watch face, you will be met with a black screen. I have only seen the emulator display the custom watch face (as a watch face, not a running activity) once and it seemed to have been a fluke.
The best way to develop custom watch faces is to run them as stand alone activities until it appears to be done, then go through the trouble of exporting a signed APK and run it on a real device connected to a real watch. At that point you can fix any small issues that remain.
please run you application on phone which has 4.3 or above platform.
install Android wear launcher apk on phone .
then connect wear emulator and phone using adb command.
adb -d forward tcp:5601 tcp:5601
I have written some program, which takes streaming data from host. I used this example: https://code.google.com/p/streamscraper/ It works fine on my Android Virtual Device (2.3.3 API level 10) but when I created .apk and installed on Galaxy S4 and LG P710 and I get error unfortunately, has stopped. Whats is wrong? How do I debug this?
Based on your comment you get the exception android.os.NetworkOnMainThreadException: In new Android APIs, You should put any code that access network or internet inside different Thread.
Try this
new Thread(new Runnable() {
#Override
public void run() {
//Put your code here
}
}).start();
Edit 1:
You can use any background threading construct that comes with Android. Thread inside Service, Thread (as mentioned) or AsyncTask. Each has pros and crons. You should investigate this. Small hint, if you play this inside this activity and access the activity user interface some how, Use AsycnTask.
To debug it on your device, you have to use ADB with your smartphone device. To do so, enable USB Debugging on the device, connect it to the computer and make sure (if on Windows) that USB drivers are installed. Finally launch Eclipse or Android Studio and launch your project in debug mode. You should see a console output, where the full stacktrace of your device is visible.
If you do not have the possibility to debug with your computer <-> smartphone, try to use BugSense. Its free and including its library into your project it sends a full stack trace to you if errors do occur.
Setup your device do be debuggable: Link.
Start a debug from Eclipse, choosing your device.
check the output in the LogCat View in Eclipse. There you will see the Exception Stack Trace.
Why don't you directly run the apk file on your device instead running on the emulator.??
Check this in manifest file that you have set
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
I'm currently working with Processing, and I would like to code an android app. I have succeeded in being able to launch may application in the android emulator, but I am not able to get it to launch on my Galaxy 2.0 tab. I click run device, but every time I do I get a message at the end that says "waiting for device to become available". I'm thinking that I may need to point Processing to my android tablet somehow. Any ideas as to what I'm doing wrong. I'm on Windows 7.
It means your device is not being detected in the eclipse debugger tool. Did you check in Tab "Developer Options", make sure USB debugging is enabled. please refer other links you may get answer.
Click here
Device not detected in Eclipse when connected with USB cable
it's clear to me that one can use ADB to run commands on connected Android device, but how does it work internally?
My assumption is that after for instance calling 'adb shell' ADB connects with some internal service running on Android device or emulator and communicates with it.
What I want to do is to connect to this service which parses ADB commands directly from device (assuming it's not connected to PC) and run ADB commands directly from device. Would it be possible?
Not as far as I know. Rooted phones can have a terminal emulator on the, but that ties directly into the phone, rather than going through the adb daemon. Depending on what you want to do, you might still be able to use the terminal emulator on a rooted phone. Check this post out: http://androidforums.com/eris-all-things-root/109607-terminal-emulators-adb-question.html
ADB is a deamon running at the native layer. It is started when the phone is started in init.rc, Androids version of init.c. ADB can take commands in Androids shell scripting language which is similar yet different to BASH.