1

I am developing an application to control the android device from one android device like control the device via input keyevent. If I want to press menu button from my application on one device will open the menu button on another device which to be controlled.

I thought to transfer some data while clicking on button on device. According to the data received from sender, it will perform the action. Please guide me to do this. What are the ways available to transfer data between two devices using API's?

UPDATE:

I have used socket to send data from one device to another device. Receiver side application is running on back ground and receiving the data which is sent by controller. According to that data, receiver will perform the action. The action is like to pressing back button on that device, if the receiving data is "back", to pressing menu button on receiver device, if receiving data is "menu"

Now my question is how to do that activities ( pressing buttons on real device ) from application?

Solution:

I used to navigate device from keyevents. Sample code is below:

                        try {       Instrumentation m_Instrumentation = new Instrumentation();
                                    m_Instrumentation.sendKeyDownUpSync(keyCode);
                            } catch (Exception e) {
                                    Log.d(TAG, "Permission denied!!!");
                            }

I'm building my app as system application by putting source into AOSP. I used user-permission to access it as

<uses-permission android:name="android.permission.INJECT_EVENTS" />

Even though, I am getting permission denied to trigger keyevents. Logcat is below:

D/ServerService(  668): down
D/ServerService(  668): down
D/ServerService(  668): down Button is pressed
D/ServerService(  668): down is pressed
W/InputDispatcher(  187): Permission denied: injecting event from pid 668 uid 10036 to window Window{41524818 com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 10023
W/WindowManager(  187): Input event injection permission denied.
D/ServerService(  668): Permission denied!!!

Question:

How to solve the above "Permission denied" issue. I have referred the link. But, It couldn't even works! remains the same issue. If anyone know the way to solve it , share.

Otherwise, If you know any other way to navigate(control) device, let me know.

Community
  • 1
  • 1
Dhasneem
  • 4,037
  • 4
  • 33
  • 47

0 Answers0