yashsingh1/xdaforums huggingface dataset:
[Android Software Development] regaw_leinad:
The

Fastboot.ExecuteFastbootCommand()

method actually returns a string containing the output of the command.
[Android Software Development] Rapscallion16:
Awesome, thanks! Now I can finally get rid of those pesky Command Prompts from my toolkits. Also, I'm rewriting my toolkits around AndroidLib, but right now they download adb.exe, AdbWinApi.dll, AdbWinUsbApi.dll and fastboot.exe in the background to ensure that CMD can access ADB and Fastboot. AndroidLib has these built in, correct? In other words, I won't need to have those files download as AndroidLib has them built in? The less files needed the better. :D
[Android Software Development] regaw_leinad:
Exactly. They are built into AndroidLib to eliminate the need of external ones :)
[Android Software Development] .torrented:
I just wanted to stop in and say this is pretty awesome, thanks for putting this together for the simple dev (myself).

I've wanted to embed this into my application, I've watched your youtube video on how to embed a .dll but when I set the references "AndroidLib" to copy local "false" I get this:

Error	1	Assembly 'I:\VB Programs\AndroidLib\AndroidLib.dll' must be strong signed in order to be marked as a prerequisite.
[Android Software Development] regaw_leinad:
You're welcome!

In Visual Studio, try:

Build > Clean Solution.

Build > Rebuild All.

If that doesn't work, try downloading the source for this project from my Github, and compiling it into a dll from there. Should fix that issue.
[Android Software Development] .torrented:
I did download the AL source and compile it to a .dll

I tried to clean solution and rebuild still no dice, it's not a huge deal, I just didn't know if i might have missed a step. I'll keep playing around with it and see if I can get it working.
[Android Software Development] Rain_Saeid:
Hi

How to use AndroidLib Commands on VB.Net :

"Reboot" Command?

"ADB Reboot Recovery" Command?

and How to use command for Download Mode for SAMSUNG Phone?

TNX
[Android Software Development] regaw_leinad:
You can view the documentation HERE and use the "Language Filter" to set it to VB.NET
[Android Software Development] Rain_Saeid:
Hi..

But i Can't Open your Page..

pls Help Me with an example..

Pls

thank's
[Android Software Development] regaw_leinad:
When you have a Device object called device, you can call

device.Reboot()

device.RebootRecovery()

and it will do just that.
[Android Software Development] Rain_Saeid:
Tnx.. very good

and For output Command?

I want to get output Command..

Can you do it with androidLib?

If it is possible, you can check an example?
[Android Software Development] regaw_leinad:
Yes, the Adb.ExecuteAdbCommand() returns the output
[Android Software Development] Rain_Saeid:
I could not run

I thank you ، If for me take an example in vb.net

pls

tnx very much
[Android Software Development] Rapscallion16:
I am trying to do this shell command.

adb shell am kill-all

.

This is how I have set it up so far, but I'm pretty sure this is wrong since I didn't form the command first.

Adb.ExecuteAdbShellCommandInputString(device, "am kill-all");

I attempted to use the FormAdbShell command, but it wanted arguments and executables, and I'm not sure what those would mean in this context. Thanks in advance for any help!
[Android Software Development] regaw_leinad:
adb shell am kill-all

The executable is the executable you want to run on the device, so in your case, "am". Then the argument that you pass to "am" in the above command is, "kill-all", so you would do it like this.

bool root = true; // Or false, whatever you need.
AdbCommand adbCmd = Adb.FormAdbShellCommand(device, root, "am", "kill-all");
Adb.ExecuteAdbCommand(adbCmd);
[Android Software Development] Rapscallion16:
Ah, that makes a lot more sense. Thanks again! :D
[Android Software Development] Rain_Saeid:
Hi

How Are u?

i Can't make output View in program (vb.net)

pls Help me For request..

TNX for Best AndroidLib

Good Lock :victory:
[Android Software Development] Beatsleigher:
What do you mean by 'output view'?

You should be more clear and not write with abbreviations, such as 'u' or 'r' for words.

It just makes everything a bit weird.

But if you mean catching the output, it should be something like: "RichTextBox1.AppendText(adb.executeAdbCommand(adb.formAdbCommand("Command"))"

I haven't been working with VB lately, I'm going a complete different direction, but that should be it.
[Android Software Development] regaw_leinad:
Yeah, just like what [MENTION=4320277]Beatsleigher[/MENTION] said, I'm having a hard time answering your posts because of two reasons. Well, really three.

Your english in the posts is not very good, so I don't completely understand what you are asking for.

The questions are very, very, very general

It sounds to me like you are trying to learn how to develop software while learning to use this API.

That last one is the big issue here. I would recommend studying VB (or any other language) until you have a great understanding of how code interacts with other code, and then try and tackle integrating a standalone library like AndroidLib. If you do that, you'll thank me in the long run, I promise. That is, unless you want to hack together some quick little utility that you don't care about the quality.

This is just my take on this. I didn't develop this library for someone to use to learn how to program, but to save developers from writing thousands of extra lines of code, and the hours spent writing that code. If you don't understand the interaction between user libraries and your own code base, or even how to make text appear in a TextBox, I would concentrate your efforts on learning the development environment and the ins and outs of the language first.
[Android Software Development] Beatsleigher:
He's right. At first, learn how to interact with your program. Learn how to add and append text to Text- and RichTextBoxes, and then you can slowly go on with with 3rd party libs and apps.

If you won't take the advice from [MENTION=2326081]regaw_leinad[/MENTION], then take this advice from me, I've been developing in VB for about five years, now:

Don't immediately dive in to it. That's what I did and it took me ages, literally ages, until I got a feeling for good and useful code.

Sure, VB is a cool thing, just as is C#, they come with the 'visual' aspect, you can design UIs in minutes. But it's not all about the UI. You can have a really shweet UI, but then again, terrible code. Learn to use console applications first. Once you've got the hang of those, you can use UIs to interact with, say, files, the Windows registry and what not.

If you want, you can try doing this:

Create an application, which starts a CONSOLE application, with several command-line arguments and gets the application's output. Then, take that output and write it to a file. Once that is complete, re-run the application with the same command-line arguments and compare the output of the second run with the output of the first run, by reading the contents of the file to which you wrote the output.

Whilst comparing, check for differences, for example errors which occurred in the first run, but not in the second one.

That's a mighty task, but can be done in both console applications and WinForms/WPF applications.
[Android Software Development] regaw_leinad:
Not sure what you really mean by that sample console application. Shouldn't an application that accepts the exact same command-line arguments return the exact same value both times? Why would it be different?
[Android Software Development] Beatsleigher:
Creating small applications like that are good for getting to know the System.IO namespace and figuring out how to collect in- and output. And, say, if we were to use adb logcat or adb dmesg, the output is never the same. There are always minor errors or system operations that get plonked in there. I was referring to something like that.
[Android Software Development] gnmmarechal:
Where is the link for the DLL?
[Android Software Development] Beatsleigher:
--- Deleted ---

Sorry for that. It slipped out, I hadn't noticed regaw had removed the link.
[Android Software Development] Rain_Saeid:
You can download this file from the following link :

https://github.com/regaw-leinad/AndroidLib
[Android Software Development] regaw_leinad:
I believe he's being serious. I used to have the compiled dll here for download.

That is the location to download the source code. [MENTION=5219349]gnmmarechal[/MENTION] you will have to download the code and compile it into a dll to use it.
[Android Software Development] gnmmarechal:
Thank you

---------- Post added at 12:52 PM ---------- Previous post was at 12:30 PM ----------

Yes, I am, do you have any problem with that?
[Android Software Development] regaw_leinad:
You're welcome. I used to provide a compiled dll, but work has been getting in the way of AndroidLib releases, so I just link to the repository for the code now, and update that whenever I find time to work on it.

It's unfortunate that you have to make these type of comments. I hadn't updated the OP and the directions said to reference the dll in VS. He also sounds like he's starting out just like you are, and doesn't know where to get everything. Not everyone possesses the moderately beginner/average programming skills you have right now, so please don't negatively comment towards anyone on my threads, thanks. On top of that, especially in the thread that contains the library your application completely relies upon, although no credit for the adb interface is given whatsoever.
[Android Software Development] yoavst:
Can someone compile a DLL for us, Noobs in C#?

and also, do you need the adb.exe files for that?
[Android Software Development] regaw_leinad:
I know the saying is

[B]If you give a man a fish, he eats it once. You teach a man to fish, you lose a business opportunity.[/B]

but since I am not planning any business ventures with AndroidLib, I'll teach you how to compile it yourself.

This is assuming you already have Visual Studio of course for C# development. (I guess you could be using Notepad and csc to compile, but have fun with that lol).

You're going to go to the Github page linked in the OP under Downloads.

Find the button that says "Download Zip". This will download all of the source code for AndroidLib as a zip file.

Unzip the zip file. You will now see the AndroidLib.sln file (possibly inside another folder). This is the Visual Studio solution.

Double-click AndroidLib.sln. This will open Visual Studio.

Build the solution in release (not debug) mode. There should be a drop down box at the top of VS that says either Debug or Release.

Just look in the bin\Release folder for AndroidLib.dll

adb.exe, its necessary dlls and fastboot.exe are included in the library, no need to add them.
[Android Software Development] Beatsleigher:
Yeah, sorry about my post a few days ago. I hadn't seen that you deleted the link to the DLL.

But then again, personally I tend to download the sources directly and build them myself.

I'm not 'just starting out', I've been developing for a few years now.

Sadly, most of that was in either Batch or VB.

I know that not everyone can code immediately, we all started somewhere.

Again, sorry. It was my mistake. It slipped out, I guess. It happens to the best of us.

Not true.

The Universal Android Toolkit that was once written in Visual Basic only used AndroidLib to a certain extent, for example getting the device info.

I was hoping to use it for getting build properties, but that feature doesn't work anymore.

The rest was literally me creating processes, redirecting the output and handling from there.

And yes, it may be true that I hadn't thanked or mentioned you in thread, but only because AndroidLib wasn't included in that version.

Rather, whilst I was still developing that version, I had mentioned and linked you directly inside the program.

See picture.

Nor is it included in the new version, which I'm currently porting to Java.

---------- Post added at 01:31 AM ---------- Previous post was at 01:11 AM ----------

Ah, while I'm thinking about it.

I replaced the old getProp method in AndroidLib.

As it doesn't work anymore, and I found a rather cewl way to get the props, I thought I'd implement it.
[Android Software Development] regaw_leinad:
No worries, I just don't want that in my threads.

Well, your version that you have up for download ships with AndroidLib. Also, you might want to not include all of the .pdb files in your download, those are used for debugging purposes only.

Not really true. It may not work on some specific devices. What do you use to test on? It works fine on all HTC devices that I've worked with so far, but Samsung devices tend to output their properties differently.

Downloaded my source fresh from Github, wrote a sample app - See picture. I'll probably end up writing an interface for the BuildProp class to use as a prop parser, then you can write your own implementation that interfaces with the library. Of course, I'm using "you" generally, since you're working with Java now.

Look into the source code for DDMS, it will help you a bunch if you're wondering about the protocol code for the adb server.
[Android Software Development] Beatsleigher:
Really?

Wow. Oops.

It's not being used, so it shouldn't be there.

I've been using that code with my Samsung Galaxy S 4 I9505 and with my HTC Desire HD. I also used it on my old GS III it worked fine on all of those.

If I remember correctly it worked on some LG devices as well.

I'm not just working with Java, I took your advice and looked into C# to see what it was like and when I noticed that, in Windows, you just can't do everything in Java I installed C# Express 2010 and have been using that to work with C# and Java simultaneously.
[Android Software Development] yoavst:
Thanks for the explain, I'll try it when my windows PC will work (my Ubuntu works fine )
[Android Software Development] Rain_Saeid:
Hi

I could not solve my Problem

I want to display the command output :

See : My Problem

tnx
[Android Software Development] Beatsleigher:
' I'm not giving any guarantee, that this will work. I haven't coded in VB for a few months now!
Import RegawMod.Android
Import System.Diagnostics
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RichTextBox1.AppendText(Adb.ExecuteAdbCommand("install <appName>"))
End Sub

I'd love to provide more examples, but I cannot. I've been coding too much Java.

And I don't think [MENTION=2326081]regaw_leinad[/MENTION] would appreciate me posting Java code in here :)

Just look in the amazing documentation he's left you. It's all in there.I'm sorry I cannot be of any real help for you, but I've moved away from .net. I occasionally code some C# for some Windows-specific stuff, but that's it. And I might advise you to step back from VB. If you're planning on doing some real hardcore coding, VB isn't the right language. And anyway, once you get used to the C-syntax (or C#'s almost-C-syntax) you can do some pretty cool stuff :)
[Android Software Development] Rain_Saeid:
Hi

My program was completed

I got into the Setup program

But when I install it on another system

The program gives error

This photo error:
[Android Software Development] Beatsleigher:
Surround the statement with a try-catch statement.

In the catch part, throw a message box.

Example:

Private Sub xY()
Try
<Statement>
Catch ex As Exception
MessageBox.Show("Error:" & ex.ToString)
End Try
End Sub

//C#
private void xY()
{
try {
Statement();
} catch (Exception ex) {
MessageBox.Show("Error: " + ex.ToString())
}

Post that here, then we can help.

---------- Post added at 07:21 AM ---------- Previous post was at 07:20 AM ----------

Edit: oh, it looks like you didn't initialize a variable.

Can you send us the code with the error?
[Android Software Development] Rain_Saeid:
solved

Thank you dear friend

My problem was solved with your help
[Android Software Development] Beatsleigher:
I doubt your problem was solved, but more shoved aside. Post the code here and then we can help.
[Android Software Development] Rain_Saeid:
Resolved

No

Resolved

Be sure to
[Android Software Development] Beatsleigher:
How can it be solved if I only gave you code for a try-statement?
[Android Software Development] Rain_Saeid:
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click

Try

device.RebootRecovery()

Catch ex As Exception

MessageBox.Show("Error:" & ex.ToString)

End Try

End Sub

------------------------ Very simple
[Android Software Development] Beatsleigher:
The code didn't solve your problem. If the error were persistent, it would throw more and more errors. You more likely fixed the variable, that was not set to the instance of an object, like I said.
[Android Software Development] DVS_Sokar:
I am a beginner C# programmer. I understand the basics but my quest of googling has not helped my situation but this thread answered a lot of my questions already.

Thanks,
[Android Software Development] regaw_leinad:
For number two, if you right click on the "References" section of your project, you can then select "Add Reference" (I think) and then browse to the AndroidLib dll that you compiled.

For number three, you would actually need to write

using RegawMOD.Android;

at the top to access most of the classes in AndroidLib

Hope this helps out!
[Android Software Development] DVS_Sokar:
I found it after exploring a little further in the namespaces =)

Follow up question.

I am writing a HTC One Max Windows Form application that uses 2 buttons to send the needed ADB commands to set the bootloader Flag.

This is the current Adb press:

adb shell

su (if needed to get a # prompt)

echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796

adb reboot bootloader

How would you suggest accomplishing this using the AndroidLib? I believe you have a method for running as Shell Root so if that is the case then:

I can run the echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796 command with that method and use a reboot command after?

Credit will of course be given for you help.
[Android Software Development] regaw_leinad:
Yep that should work just like you said it. If not, you can always use su's command line option -c to send it a command and exit automatically
[Android Software Development] DVS_Sokar:
Something like

AdbCommand AdbShellCmd = Adb.FormAdbShellCommand(Device, true, "input", "echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796");
[Android Software Development] regaw_leinad:
The "input" command isn't what you're looking for I don't think.

Something along the lines of

AdbCommand adbCmd = Adb.FormAdbShellCommand(device, true, "echo", "-ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796");
Adb.ExecuteAdbCommand(adbCmd);
[Android Software Development] DVS_Sokar:
Lastly,

I suppose I need to define "device" as I am getting a error on that argument. As it doesn't exist.

I don't understand the context of Device or perhaps Syntax of that object.
[Android Software Development] regaw_leinad:
This might help. You need to get the Device object and assign it to a variable.

https://github.com/regaw-leinad/AndroidLib-Samples-C-/blob/master/BuildPropDemo/Form1.cs#L40
[Android Software Development] DVS_Sokar:
This is my code for the button to lock the bootloader. It seems the Command line is not being passed through as expected. The program runs with no exceptions but when I boot into the bootloader the flag is still Unlocked.

private void lockboot_Click(object sender, EventArgs e)
{
string serial;
android = AndroidController.Instance;
android.UpdateDeviceList();
serial = android.ConnectedDevices[0];
device = android.GetConnectedDevice(serial);
AdbCommand adbCmd = Adb.FormAdbShellCommand(device, true, "echo", "-ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796");
Adb.ExecuteAdbCommand(adbCmd);
lbllocked.Visible = true;
lblunlock.Visible = false;
textboxcolor.BackColor = Color.Red;
}

Could this be because of the length of the arguments or the PIPE? been reviewing that code all and it's got me stuck.
[Android Software Development] DVS_Sokar:
Any ideas?
[Android Software Development] Beatsleigher:
Try this:

private void lockboot_Click(object sender, EventArgs e)

{

string serial;

android = AndroidController.Instance;

android.UpdateDeviceList();

serial = android.ConnectedDevices[0];

device = android.GetConnectedDevice(serial);

AdbCommand adbCmd = Adb.FormAdbShellCommand(device, true, "echo", "-ne \"\x00\x00\x00\x00/\" | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796");

Adb.ExecuteAdbCommand(adbCmd);

lbllocked.Visible = true;

lblunlock.Visible = false;

textboxcolor.BackColor = Color.Red;

}[
[Android Software Development] DVS_Sokar:
No Joy using the Escape method.
[Android Software Development] Beatsleigher:
Ok. Let me have a look.
[Android Software Development] DVS_Sokar:
private void lockboot_Click(object sender, EventArgs e)
{
string serial;
android = AndroidController.Instance;
android.UpdateDeviceList();
serial = android.ConnectedDevices[0];
device = android.GetConnectedDevice(serial);
AdbCommand adbCmd = Adb.FormAdbShellCommand(device, true, "echo", "-ne \"\x00\x00\x00\x00\" | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796");
Adb.ExecuteAdbCommand(adbCmd);
lbllocked.Visible = true;
lblunlock.Visible = false;
textboxcolor.BackColor = Color.Red;
}

I think this has to do more with how the Command and arguments are expressed in my code.
[Android Software Development] DVS_Sokar:
Perhaps I should use:

Adb.ExecuteAdbCommandNoReturn(adbCmd);

Though if I run the adb shell su command in a command prompt it does return after success;

root@t6wl:/ # echo -ne 'HTCU' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796

echo -ne 'HTCU' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796

4+0 records in

4+0 records out

4 bytes transferred in 0.007 secs (571 bytes/sec)
[Android Software Development] regaw_leinad:
Use false for a root shell, and try using the command

Adb.FormAdbShellCommand(device, false, "su", "-c \"echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796\"");

The command line option 'c' tells the shell to execute the following command and exit.

Also, the Adb.ExecuteAdbCommandNoReturn() method is there for commands that you do not care about anything written to stdout/err. It just runs the command and exits without retuning anything to the program.
[Android Software Development] DVS_Sokar:
The Syntax of the code in you last quote is erroring out. funny enough when I remove the second Double Quotes on the End of the code the Visual Studio IDE shows now issues.

Adb.FormAdbShellCommand(device, false, "su", "-c \"echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796\"");

So I ran it both ways and still it is not executing the flag change in the mmc block.

What has not worked:

Adb.FormAdbShellCommand(device, false, "su", "-c \"echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796\");

Adb.FormAdbShellCommand(device, false, "su", "-c echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796");

Here is the output from a successful mmc update in command prompt:

C:\Users\Phoenix>adb shell

shell@t6wl:/ $ su

su

root@t6wl:/ # echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796 of=/dev/block/mmcblk0p3 bs=1 seek=33796

4+0 records in

4+0 records out

4 bytes transferred in 0.007 secs (571 bytes/sec)

root@t6wl:/ # exit

exit

shell@t6wl:/ $ exit

exit

C:\Users\Phoenix>

I noticed in Command prompt if I start the first command as:

adb shell su

The prompt changes to hash but then the command prompt will not take any more commands in the command prompt.

As such we can exclude the last 2 exit commands as the flag will occurs after invoking the Echo command string. I have noticed that my phone is not showing the normal Android banner for Superuser when execution the command in the current and former iterations of the code. Which leads me to believe that the superuser shell is not triggering and that's why the echo command fails.

While not that verse in C# that's what appears to be the case.

Thanks for your continued help on this.