Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Android
Hello Guys,
 
I am working on android ADB commands to take a back up from android device. I use this command to take backup "-s xxxxxxxxxxxxxx backup -apk -all -f backup.ab" from Mobile device when I used this command a pop up display in mobile (Take backup/Do no take backup). I touched the take backup and everything working fine. Now when I have on android dongle when I used same command to do this then how can I click on options which I got in mobile because android stick/dongle don't have screen. I am stuck with this issue.
 
Sorry for wrong engish.
 
Below are the code
 
 Process p = new Process();
            p.StartInfo.FileName = @"adb.exe";
            p.StartInfo.Arguments ="-s xxxxxxxxxxxxxx backup -apk -all -f backup.ab"; //"   ";
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            p.StartInfo.CreateNoWindow = true;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.Start();
            string regular = p.StandardOutput.ReadToEnd();
            string error = p.StandardError.ReadToEnd();
 
Thanks
Posted 17-Jun-13 4:56am
Edited 17-Jun-13 5:08am
v2
Comments
Prasad Khandekar at 17-Jun-13 10:37am
   
Try issuing adb shell input keyevent 23 command from another thread.
raghav.softobiz at 17-Jun-13 11:32am
   
Thanks for showing me right path.
Prasad

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Using Process.Start is no different than if you launched the command yourself from Explorer. What you launch is not part of your process. It runs completely independent of your code.
 
If there is no command line argument to tell it what to do, then you'll have to use something along the lines of SendKeys[^] to send appropriate keystrokes (not mouse clicks!) to the other application to get it to do what you want. Be warned...SendKeys is not reliable!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 155
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 17 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100