[Q] Posting Notifications from Shell - Android Software/Hacking General [Developers Only]

Is there anyway to post to the android notification bar from simple shell commands?
I have a script which I run using cron on my linux box which monitors some mission critical services for my business and I would like to port it to my Galaxy Nexus. It's a simple bash script which simply monitors the services with netcat.
I have tried a couple of market apps which don't work.

If you consider installing SL4A on your phone, you have a very powerful environment to make your scripts and doing what you ask requires only a
Code:
droid.notify('title', 'message')
You could even have something like this
Code:
from socket import *
import android, os, time, datetime
droid = android.Android()
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(('',2800))
Volume()
while 1:
data,addr = UDPSock.recvfrom(4*1024)
if not data:
break
else:
droid.notify(str(addr[0]), data) #Make a notify in the bar
droid.makeToast(data) #Make a small msg
droid.dialogCreateAlert('MSG_FROM:' + str(addr[0]),data)
droid.dialogShow() #Big on screen alert
UDPSock.close() # rly?
Code is just a PoC... actually uses python and opens port 2800 UDP on your phone, if you send a packet via udp to your phone, a msg will be displayed (3 times in 3 different ways, unless you remove some line ). You could then make your PC scripts send a packet to your phone and have your notification displayed.
Look into this and this

ell3,
Thanks for the quick reply. I think that's exactly what I was looking for!
Cheers!

Related

palm2droid: a script to help import palm addresses into your android phone

Finally I seem to have completed my conversion script which can be used to convert a palm address CSV file as output by the pilot-addresses tool (from the linux pilot-xfer suite of tools) to a sql script which can be used with sqlite3 to load the addresses into an android contacts db.
This is useful if you do not want to use the google contact service to transfer your old contacts to your new phone. Perhaps you like keeping your contacts' info private for them. Afterall, there's hardly a less public way to expose their personal data then to give it to google, the largest search provider, eh!!!
Since there is not a perfect match between palm fields and android fields, your results may vary. The script makes a best attempt to match things logically, it even tries to combine entries with the same name (in case you have multiple addresses for a person). If you have non US addresses, you should probably edit the country list in the BEGIN{} section.
Once you have converted your palm db to sql, you may want to check the transformation visually before loading it to your phone.
HowTo:
1) Before loading your palm db onto your phone, it makes sense to make a backup of your droid contacts to your PC like this:
adb pull /data/data/com.android.providers.contacts/databases/contacts.db .
2) Output your palm db to a file with the linux pilot-xfer tool (note the important -a switch):
pilot-addresses -a -w add.palm
3) Convert the add.palm created above like this:
palm2droid < add.palm > droid.sql
4) Load the sql onto your phone like this:
adb push droid.sql /cache/droid.sql
5) Load the sql into your contacts db like this:
adb shell
su
sqlite3 /data/data/com.android.providers.contacts/databases/contacts.db < /cache/sroid.sql
That's it!
If you do not like your results, restore your contacts db like this:
adb push contacts.db /data/data/com.android.providers.contacts/databases
Good luck, I hope this helps!
Download: palm2droid (GPLed)

WiFi and 3g simultaneously Guide - need help following instructions

Hi,
I currently try to follow these instructions...
http://mobisocial.stanford.edu/news...together-by-hacking-connectivityservice-java/
Very hard for me. Don't know what to do.
The goal of COIN project is to use WiFi and 3G connections simultaneously. So it conflicts with the policy of Connectivity Service, but there is no configuration to edit the policy, and it is hard coded. You can find the clue in ConnectivityService.java:handleConnect function.
Our current solution is quite brutal, which is to mask the eyes of Connectivity Service by modifying its message handler entry like the following:
// must be stateless – things change under us.
private class MyHandler extends Handler {
@Override
public void handleMessage(Message msg) {
NetworkInfo info;
//added by COIN to disable Connectivity Service
int networkState = 8; //not any following state
/*use static google dns server for wifi and 3g*/
if (msg.what == NetworkStateTracker.EVENT_STATE_CHANGED) {
SystemProperties.set(“net.dns1″, “8.8.8.8″);
SystemProperties.set(“net.dns2″, “8.8.4.4″);
bumpDns();
}
//////////////////////////////////////////////
//switch (msg.what) {
switch (networkState) {
case NetworkStateTracker.EVENT_STATE_CHANGED:
info = (NetworkInfo) msg.obj;
int type = info.getType();
…..
And then compile the modified ConnectivityService.java in the android source code tree, you can get an new services.jar file in framework directory. Replace the existing services.jar on the cell phone with the following adb commands, then reboot the phone
adb shell “mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system”
adb shell “chmod 0777 /system/framework”
adb push services.jar /system/framework
adb shell “chmod 0644 /system/framework/services.jar”
adb shell “chmod 0755 /system/framework”
Click to expand...
Click to collapse
Does he mean I have to compile the whole Android source code again?
So I would need to learn first, how to compile Android, then change this file, compile Android, copy file?
Instant of adb shell, could I also use root explorer?
How device dependant is this? Or how android version dependant?
Could someone offer the compiled file?
No answer yet.
I believe so. This is actually what compelled me to go learn to compile android by myself-- the constant switching between 3g and wifi in a semi-strong wifi zone sucks. For now I am starting with CM7 since it is so popular.
Yes you would need to compile the whole OS and it will only work on an AOSP rom. It will also be very version dependent.
Please let me know if it worked ! I probably don't think it will. Read this on the page:
Pallas Says:
April 13, 2012 at 5:58 am
are you sure the packets are going thru both interfaces?
I think it doesn’t work, simply because you would need two default gateways, leading to some hard problems:
- how does the system choose where to send the packets?
- for outgoing packets: unless the two connections have both statically assigned public IP addresses, which is very unlikely, you will end up with two differently NATed paths, and the client will refuse packets coming from two different ip addresses on the same connection.
- for incoming packets: to let the client send packets to both interfaces, you would need to send them from both interfaces with different source ip addresses: it will not work, the client will get confused. and anyway you would need support at the application level.
to solve all this, you’d need to:
- make an ad-hoc application which understands all this and can send chuncks to both interfaces, then merge all the returning chunks. you’d need support at the application level: for example you’d need http byte range support on both client and server
- divide “equally” the single specific connections thru the two gateways. this may work but it’s pretty hard if you do not have access to advanced routing and traffic shaping at the kernel level. may be possible on a phone with custom compiled aosp rom and modified kernel
gouthamsn said:
Please let me know if it worked ! I probably don't think it will. Read this on the page:
Pallas Says:
April 13, 2012 at 5:58 am
are you sure the packets are going thru both interfaces?
I think it doesn’t work, simply because you would need two default gateways, leading to some hard problems:
- how does the system choose where to send the packets?
- for outgoing packets: unless the two connections have both statically assigned public IP addresses, which is very unlikely, you will end up with two differently NATed paths, and the client will refuse packets coming from two different ip addresses on the same connection.
- for incoming packets: to let the client send packets to both interfaces, you would need to send them from both interfaces with different source ip addresses: it will not work, the client will get confused. and anyway you would need support at the application level.
to solve all this, you’d need to:
- make an ad-hoc application which understands all this and can send chuncks to both interfaces, then merge all the returning chunks. you’d need support at the application level: for example you’d need http byte range support on both client and server
- divide “equally” the single specific connections thru the two gateways. this may work but it’s pretty hard if you do not have access to advanced routing and traffic shaping at the kernel level. may be possible on a phone with custom compiled aosp rom and modified kernel
Click to expand...
Click to collapse
(Probably for your Interest
This project works on a MultiPath-TCP Implementation (follow link to mptcp.info.ucl.ac.be). The hard times you get is compiling the Kernel with the additional files. This Protocol can only work effectively for download Purposes if the Server also has a MPTCP Kernel running. But on the other Hand you can shut down a single connection without loosing the active Connection (Downloads are not interrupted and improved Bandwidth Capacity if your Server is MPTCP-Ready)
Until now this Protocol is only working for Homeservers or similar Projects, where you have full access to the Server and the working Kernel of the system.
I am currently working on implementation of the Protocol for my Bachelor Thesis. I already compiled a working Kernel (Glados Nexus S) and now i'm working on keeping both Interfaces active. I hope this Tut can help me...
Has anybody tried other approaches to this topic? I tried manually loading the wifi-module and configuring it, but i only managed to ping via one Interface.
You managed to make it work?
bagers said:
No answer yet.
Click to expand...
Click to collapse
You managed to make it work? i want to make it also for my master thesis

Tutorial - Port knocking w/ ssh, vnc - Secure access from android to remote computer

What I wanted was a simple, secure way to access my home computer remotely from my android phone. I know there are vpn options but I’ve seen that cause battery drain issues if in constant use, and also is more than I wanted/needed to setup. I know I could just setup a ssh server but leaving port 22 open on the remote computer for anyone to scan and hack the password seemed too insecure for me. So I came up with this solution and have been using it for about 2 years now without any problems. I thought maybe I should share this method since it may be of use to someone else and I don’t know of anyone else putting all these together for use with android.
What this does:
By running a small script on your android phone in terminal (only 2 commands), your phone knocks 3 specific ports, in a specific order (like a combination lock), your remote computer recognizes this order and opens port 22 for 10 sec. Your script then ssh’s the remote computer on port 22 and you log in. The port 22 on the remote computer closes so no one else can see it, but the keep-alive feature keeps your ssh session open so you can do whatever you need, for as long as your like, without worrying about someone port sweeping the remote computer and seeing the port open, or brut forcing a ssh password on it. You with me so far?
Now the ssh session also uses port forwarding to forward port 5900 from the remote computer to port 5900 on the localhost of the android phone. Now you can open your vnc client and connect to the remote computer through your ssh tunnel and see your x11 desktop. So you know also have a secure VNC connection! All this is done securely and only runs ondemand.
While this may look like a lot to setup, it’s actually quite easy and should only take about 15min tops. This tutorial should be complete but if I’ve forgotten anything, let me know and I’ll be sure to update this page.
In other words, run two simple commands within a script and you have secure access to your remote computer from your phone! Enjoy!
Pros:
- Secure
- Works on 3G and wifi
- Runs on all android versions
- Works on all x11 GUI’s (gnome, kde, etc). Assuming a VNC session is also desired.
- Fun!
Problems:
- This only works on linux computers, although I’m sure there is a way to setup port knocking on windows. I have no use for this, but if people are interesting, I can add a way to my tutorial as well.
Howto:
Setup Remote Computer:
First we need to setup the remote computer. This is geared towards Debian/Ubuntu but small adjustments should have it working on all distros (I’m using Debian Squeeze personally). Let’s begin:
First we need to install a few packages if not already there:
Code:
apt-get install openssh-server x11vnc knockd
Now lets configure your ssh daemon. Using nano or another text editor, edit /etc/ssh/sshd_config:
Change the following line to read as follows:
Code:
PermitRootLogin no
This will disable root login, so you will login in as a user and then su to root (You can leave root login if desired, it’s just less secure and not recommended).
Next we need to edit our iptables, so open /etc/network/if-pre-up.d/iptables and add the following:
MAKE A BACKUP FIRST OF THIS FILE
Code:
# Accepts all established inbound connections
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
iptables -A OUTPUT -j ACCEPT
# Allow ping
iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
# log iptables denied calls (access via 'dmesg' command)
iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
# Reject all other inbound - default deny unless explicitly allowed policy:
iptables -A INPUT -j REJECT
iptables -A FORWARD -j REJECT
Now we setup our port knocking. Edit /etc/knockd.conf:
Code:
[options]
UseSyslog
[openSSH]
sequence = port1,port2,port3
seq_timeout = 5
command = /sbin/iptables -I INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
cmd_timeout = 10
stop_command = iptables -I INPUT -p tcp -m state --state NEW --dport 22 -j DROP
tcpflags = syn
[closeSSH]
sequence = port1,port2,port3
seq_timeout = 5
command = /etc/init.d/ssh stop
tcpflags = syn
The section [openSSH] is what opens the port for 10 sec by running the iptables command and then drops the packets after the time expires, running the stop_command. The section [closeSSH] is not needed. It was a failsafe I use in case I want to disable ssh if I thought I was getting hacked and could not login. This is also left to show how you can use the knocking to run different commands using another sequence of ports (for ftp, etc.)
Now lets restart the network interface and restart the knock daemon:
Code:
ifconfig eth0 down #adjust to whatever interface you use normally
ifconfig eth0 up
dhclient
/etc/init.d/knockd restart
/etc/init.d/sshd restart
Test your internet and make sure it works. To make sure you have it setup to run on boot, first determine your runlevel:
Code:
runlevel
Make sure knockd, ssh are in the /etc/rcX.d (where X equals your runlevel). If not, add it
Code:
ln -s /etc/init.d/knockd /etc/rcX.d/S02knockd
And so on for shh if needed, (again, adjust X to equal your runlevel)
Setup X11VNC password:
Code:
x11vnc --store password
create a script for ~/bin/x11vncserver
add this to the script
Code:
#!/bin/bash
x11vnc -safer -forever -usepw -noxdamage
The “-noxdamage” fixes a display problem of the desktop not updating in the android vnc client. Now if using gnome and you only care about vnc login for one user then, goto System → Preferences → Startup Applications → Add →
Name = VNC Server
Command = x11vncserver &
Or add to GDM for access to any user, add to /etc/gdm3/Init/Default:
Code:
x11vnc -safer -forever -usepw -noxdamage
DONE! (KDE will be similar but slightly different to load on login, post if help is needed)
Setup android phone:
create script called knockh in /system/xbin. Then add this:
Code:
nc -z [ipaddress] port1 port2 port3
ssh -L 5990:localhost:5900 [email protected][ipaddress]
Replaces the ipaddress with your own (google “what is my ip” if you don’t know your external ip). Replace the ports with the ones used in the config file above for knockd. Change the user to whatever user has ssh rights. Then
Code:
chmod 755 /system/xbin/knockh
Now run knockh in the terminal and you should see a login for ssh on your remote computer.
Next download “android-vnc-viewer” from the market (it’s free). Create a new connection by selecting “new” from the dropdown box.
Create a nickname, enter your x11vnc pasword, address is “localhost” and port is “5900”. For 3G connections, I recommend 8 colors, for wifi 256. I also check the “Local mouse pointer” in the checkbox. Now click connect and see your desktop!
(If you are on your local wifi network be sure to create another connection for your local ip address)
Fixes:
Keep in mind this is for remote networks, if you are on your local lan, this won’t work without changing the ip address.
If using a router or modem, setup port forwarding to your remote computer for TCP ports 5900, 22, port1, port2, port3 (your port knocking ports). Also make sure to setup a static dhcp for the remote computer so your router/modem doesn’t change it’s ip address and you can’t connect.
If you are using an ISP that doesn’t give you a static ip address for your router, you will not be able to login whenever they change it, you’ll have to update the script first with the new IP. A solution is to setup a dynamic dns, using dyndns.org or something similar. Free options are out there, just google it.
I hope this helps, please post if you have any questions, comments, etc. Enjoy!
-Mike
On some roms, the busybox version of "nc" does not allow the -z command for knocking the proper ports. I've pulled the version of it from CM 7.2 and put in my /system/xbin and full functionality has been retained. I've included both "nc" and "ssh" here and they should work fine if you are missing them. (Tested on my EVO LTE running mostly stock Sense ICS, but this is fine for other android versions)
nc
ssh
Hope this helps!
-Mike

[GUIDE] How To Install and Use Android SDK

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
*If you find this Guide Thread helpful, feel free to hit the "thanks" button below!​
What is Android SDK?
Everyone wants to program on Android; unfortunately, not everyone knows quite how to get started with their development environment. Google has put out both the Android SDK and the Android ADT in order to help developers integrate Android into their dev environment as well as facilitate more Android development. In this guide, we’ll take a look at how to set up a development environment for Android so you can start creating projects. Android SDK and Android ADT are essentials that you will need to include in your Android Developer Toolbox for use with many things, and can be a very powerful set of components from the simple, to the complicated. When it comes to Android modding, most novice users are confused or left wondering by reference over reference to a certain “adb”. This is specially true when you are looking up something on modding your device, or root it in particular. ADB is the wonder toy of Android and everyone seems to love it, so lets have a look at understanding what it is and why you need it, and how you can get it.​
What is ADT?
ADT (Android Developer Tools) is a plugin for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE. It offers you access to many features that help you develop Android applications quickly. ADT provides GUI access to many of the command line SDK tools as well as a UI design tool for rapid prototyping, designing, and building of your application's user interface. Because ADT is a plugin for Eclipse, you get the functionality of a well-established IDE, along with Android-specific features that are bundled with ADT. The following describes important features of Eclipse and ADT:
Integrated Android project creation, building, packaging, installation, and debugging
ADT integrates many development workflow tasks into Eclipse, making it easy for you to rapidly develop and test your Android applications.
SDK Tools integration
Many of the SDK tools are integrated into Eclipse's menus, perspectives, or as a part of background processes ran by ADT.
Java programming language and XML editors
The Java programming language editor contains common IDE features such as compile time syntax checking, auto-completion, and integrated documentation for the Android framework APIs. ADT also provides custom XML editors that let you edit Android-specific XML files in a form-based UI. A graphical layout editor lets you design user interfaces with a drag and drop interface.
Integrated documentation for Android framework APIs
You can access documentation by hovering over classes, methods, or variables. ​
What is ADB?
ADB stands for Android Debug Bridge. It comes as a part of the standard Android SDK, which you can grab here in this guide. Basically, it provides a terminal-based interface for interacting with your phone’s file system. Since Android platform is based on Linux, command-line is sometimes the only way to obtain and manipulate root access often required to perform certain advanced operations on your device using root access. While these things can be done directly on the device itself using some terminal emulator, it will be rather difficult to execute complex commands on such a small screen. ADB provides the bridge between your machine and your computer.​
Preface: Dev Environment Notes:
Just a general rule to reduce headaches, if you're serious about Android development, your development machine should primarily be a development machine, as installation of other various programs may clutter it up and produce unexpected errors or other bizarre happenings. While this is rare, it’s not uncommon, and an exclusive development machine is recommended. If an extra machine is not available, a virtual machine used as a development machine works very well also. If this isn't an option either, you can always install Ubuntu 12.04 on your Windows PC and select whichever operating system you'd like at boot/reboot. The latter is my setup, since I run Windows 7 primarily, and Ubuntu for selected other functions -namely Android SDK. It's all your preference here, but keep in mind that if you start getting too deep in the rabbit hole with your Android development, you may want to consider a dedicated dev machine, or re-partition your Ubuntu setup to allow for more capabilities within it.​
Step 1: Install the JDK
Most of you probably have the Java JRE installed, but Android requires the JDK “Java Development Kit” to compile Java programs. The JDK is available on Oracle’s Java webpage. Install the version of the JDK appropriate for your OS; the Java EE 6 bundle is recommended, but you can install any bundle you like so long as it contains the JDK.
(Getting started on Ubuntu, see THIS PAGE)
Getting started on Windows:
Your download package is an executable file that starts an installer. The installer checks your machine for required tools, such as the proper Java SE Development Kit (JDK) and installs it if necessary. The installer then saves the Android SDK Tools into a default location (or you can specify the location). Make a note of the name and location of the SDK directory on your system—you will need to refer to the SDK directory later, when setting up the ADT plugin and when using the SDK tools from the command line. Once the tools are installed, the installer offers to start the Android SDK Manager. Start it and continue with the installation guide by clicking the Next link on the right. The Android SDK requires JDK version 5 or version 6. If you already have one of those installed, skip to the next step. In particular, Mac OS X comes with the JDK version 5 already installed, and many Linux distributions include a JDK. If the JDK is not installed, go to http://java.sun.com/javase/downloads and you'll see a list of Java products to download.
Linux users: Many Linux distributions come with an open source variant of the JDK, like OpenJDK or IcedTea. While you may be tempted to use these in support of open-source or for whatever reason, for maximum compatibility install the official Oracle JDK. You may choose to ignore this warning, but you may end up encountering obscure, strange errors because of it; if you do, most likely it’s some minor difference in the two JDKs.​
Step 2: Install Your IDE of Choice
You can by all means code straight up in Emacs or Vi; if you prefer doing that, this guide is not for you. For the rest of us, install a Java IDE; Eclipse is recommended as it is the IDE that the Android developers use and the IDE with official plugin support from Google. The rest of this guide will assume Eclipse is the IDE you’re using, but NetBeans has Android plugin support for it as well. When you download Eclipse, make sure to download Eclipse Classic or Eclipse for Java EE developers; there are quite a few flavors of Eclipse for download on their page, and you don’t want to end up with the C++ or PHP versions of Eclipse.
Obtain Eclipse
These alternatives may be available to obtain a copy of Eclipse for installation:
Download a current stable build of Eclipse from the Eclipse Web Site; note that the installation file is large (over 120 MB)
For the recommended package to download and install, click the link Eclipse IDE for Java EE Developers on the Eclipse Packages page. For the reason why this is the recommendation, see the following bullets:
There are a number of downloadable packages available, each a different "flavor" of Eclipse, which can be compared and contrasted from the Compared Eclipse Packages page. The recommended Eclipse package is the Eclipse IDE for Java EE Developers. This recommendation is made for those who develop in other languages / on other platforms as well, for the following reasons:
The "slimmer" Eclipse IDE for Java Developers lacks data tools, testing support, and parts of the Web Standard Tookit useful to all Java web application developers
The Eclipse Classic seems like it ought to be "slimmer" but in fact it is a larger download than the JEE package. Downloading and installing this package, then picking and choosing among additional packages described on the Eclipse Classic page is a viable alternative, but requires each developer to spend time researching the contents and utility of the multiple options.
Install Eclipse
There is no installer (executable program) used to install Eclipse. The process described below involves un-archiving (unzipping) a directory tree of files and placing it in an appropriate location on your hard disk. It is very strongly recommended that you locate the eclipse\ directory at the root of your computer's hard drive; or, minimally, on a directory path with no spaces in its name (e.g., C:\mystuff\eclipse\. It is worth noting that Eclipse does not write entries to the Windows registry; therefore, you can simply delete (or move) the installed files, shortcuts, and/or the workspace: there is no executable uninstaller either.
Unzip (or copy/unjar/check-out) the software into an appropriate location on your hard disk (e.g., C:\eclipse).
These instructions are written assuming that you are running eclipse from C:\eclipse; if you are using a different path, adjust accordingly.
Once the unzipped (copied/unjarred/checked-out) files are located on your filesystem, get started using Eclipse:
Run Eclipse by running C:\eclipse\eclipse.exe
The first time you run Eclipse, you will be prompted to identify a location for your Eclipse workspace. This is where local copies of your projects (files you check in and/or out of code repositories) will live on your file system. Do not create the workspace in a directory path that has spaces in it - i.e., not in the default C:\Documents and Settings\... directory presented by default on the first startup of Eclipse. Instead, it is recommended that your workspace be located at the root of your machine's hard disk, e.g., C:\workspace.
It is advisable to pass JVM arguments to Eclipse at startup to reserve a larger memory space for the IDE than the default. To, specify recommended JVM arguments, create a shortcut (probably on your desktop) with the following target (modified if you're using different directories):
Code:
C:\eclipse\eclipse.exe -jvmargs -Xms128m -Xmx512m -XX:MaxPermSize=128m
Step 3: Install the Android SDK
Now it’s time to install the Android SDK. You can grab it from the Android Developer website at:
http://developer.android.com/sdk/index.html​
Download the installer for your particular operating system, and open it up when you’re done:
Android SDK Manager
The Android SDK Manager is modular, meaning that you download the initial package and then download separate packages within the framework in order to provide more functionality. This lets the SDK be more flexible, as you don’t need to keep downloading entire packages every time a new version comes out; you can simply download the latest module and pop it into the SDK. You can pick and choose which modules to install, but if you’ve got the hard drive space I recommend installing all of the different flavors of Android; it will help later when debugging apps, especially on older Android OSes.​
Step 4: Install the Android ADT for Eclipse
NOTE: if you’re using NetBeans, you want the nbandroid plugin, found here:
http://kenai.com/projects/nbandroid/pages/install​
Now that the SDK is installed, you should install the Android ADT plugin. It’s not strictly necessary to do so, but the ADT offers powerful integration with many of the Android tools, including the SDK Manager, the AVD Manager, and DDMS, or dynamic debugging. All of these are extremely useful to have when creating an Android application, and if you want to skip them you should do so at your own peril!​
Eclipse ADT Plugin
To install the ADT, you’re going to have to add a custom software package to Eclipse. To do so, head over to the “Help” button on Eclipse’s menu and click the “Install New Software” button. Click “Available Software”, click “Add Remote Site”, and pop in this URL:
https://dl-ssl.google.com/android/eclipse/​
Eclipse ADT Install
Occasionally, for whatever reason, some people have trouble downloading the ADT from that secure site. If you’re having issues downloading the ADT, simply remove the “s” off the end of the “https”, and the download should work as intended. Once that’s done, head back over to the Available Software tab and check the boxes for Developer Tools, Android DDMS, and Android Development Tools; again, none of these are mandatory, but they’re all going to be very useful later on. The packages will take a bit to download; once they’re done, restart Eclipse!​
Step 5: Create an Android Virtual Device (or AVD)
Like the previous step, this step isn’t entirely necessary; you could do all your debugging and development work on an actual Android handset. Creating AVDs is a great way to see how your application might work across different operating systems and handset types, as AVDs can mimic not only different Android OSes but also different hardware; you can change such settings as heap size, display type, and maximum memory, making it useful to try and figure out where bugs are happening when you don’t own a multitude of different handsets to test on! To create an AVD, you can open the Android AVD manager from Eclipse from the “Window” button on the top bar, and go to “Virtual Devices”. From there, you can add, configure and delete them:
Android Virtual Device (AVD) Manager
NOTE: This isn’t IDE specific. For those of you running a different IDE, the AVD Manager can be accessed in the same manner as the Android SDK is accessed outside of Eclipse; this is just a very easy shortcut for those with the Android ADT installed. Need More Help? Try this 30-minute video put together by Guy Cole, that walks you through the complete step-by-step setup.​
So, You've Installed Android SDK, Now What?
The Android platform provides support for both speech recognition and speech synthesis. In this tutorial, we will create a simple Android app which allows the user to speak, attempts to recognize what they say, and then repeats what was recognized back to them using the Text To Speech engine.
Step 1: Start an Android Project​
Create a new Android project in Eclipse. Alternatively, if you want to implement the speech recognition functionality in an existing app, open it instead. For this tutorial we have a minimum SDK version of 8, and you do not need to make any particular additions to your Manifest file, the default contents should suffice.
Step 2: Define the User Interface​
Let’s start by defining the user interface. When the app launches, the user will be presented with a button. On pressing the button, the app will prompt them to speak, listening for their voice input. When the speech recognition utility processes the speech input, the app will present a list of suggested words to the user. As you’ll know if you’ve tried speech recognition as a user, the recognizer is not always accurate, so this list is essential. When the user selects an item from the list, the app will speak it back to them using the TTS engine. The TTS part of the application is optional, so you can omit it if you prefer.
The app is going to use a few text Strings as part of the interface, so define them by opening the “res/values/strings.xml” file and entering the following content:
Code:
<resources>
<string name="intro">Press the button to speak!</string>
<string name="app_name">SpeechRepeat</string>
<string name="speech">Speak now!</string>
<string name="word_intro">Suggested words…</string>
</resources>
Of course, you can alter the String content in any way you like.
Open your “res/layout/main.xml” file to create the main app layout. Switch to the XML editor if the graphical editor is displayed by default. Enter a Linear Layout as the main layout for the app’s launch Activity:
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
androidrientation="vertical"
android:background="#ff330066"
androidaddingBottom="5dp" >
</LinearLayout>
The Linear Layout contains various style declarations including a background color. Inside the Linear Layout, first enter an informative Text View:
Code:
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/intro"
androidadding="5dp"
android:textStyle="bold"
android:textSize="16dp"
android:gravity="center"
android:textColor="#ffffff33" />
Notice that the Text View refers to one of the Strings we defined. It also sets various display properties which you can alter if you wish. After the Text View, add a button:
Code:
<Button android:id="@+id/speech_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/speech" />
The user will press this button in order to speak. We give the button an ID so that we can identify it in the Java code and display one of the Strings we defined on it. After the button, add another informative Text View, which will precede the list of suggested words:
Code:
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidadding="5dp"
android:text="@string/word_intro"
android:textStyle="italic" />
Again, this Text View uses a String resource and contains style properties. The last item in our main.xml Linear Layout is the list of suggested words:
Code:
<ListView android:id="@+id/word_list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
androidaddingLeft="10dp"
androidaddingTop="3dp"
androidaddingRight="10dp"
androidaddingBottom="3dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/words_bg" />
The List View will be populated with data when the app runs, so we give it an ID for identification in Java. The element also refers to a drawable resource, which you should add to each of the drawables folders in your app’s “res” directory, saving it as “words_bg.xml” and entering the following content:
Code:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true">
<gradient
android:startColor="#ff000000"
android:endColor="#ff000000"
android:centerColor="#00000000"
android:angle="180" />
<corners android:radius="10dp" />
<stroke
android:width="2dp"
android:color="#66ffffff" />
</shape>
This is a simple shape drawable to display behind the List View. You can of course alter this and the List View style properties if you wish. The only remaining user interface item we need to define now is the layout for a single item within the list, each of which will display a word suggestion. Create a new file in “res/layout” named “word.xml”and then enter the following code:
Code:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
androidadding="5dp"
android:textColor="#ffffffff"
android:textSize="16dp" >
</TextView>
Each item in the list will be a simple Text View. That’s our interface design complete. This is how the app appears on initial launch:
Step 3: Setup Speech Recognition​
Now we can implement our Java code. Open your app’s main Activity and add the following import statements at the top:
Code:
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.TextView;
You may not need all of these if you do not implement the TTS functionality – Eclipse should highlight imports you have not used so check them when you finish coding. Extend your opening class declaration line as follows, altering the Activity name to suit your own:
Code:
public class SpeechRepeatActivity extends Activity implements OnClickListener, OnInitListener {
The “OnInitListener” is only required for the TTS function. Add the following instance variables inside your class declaration, before the “onCreate” method:
Code:
//voice recognition and general variables
//variable for checking Voice Recognition support on user device
private static final int VR_REQUEST = 999;
//ListView for displaying suggested words
private ListView wordList;
//Log tag for output information
private final String LOG_TAG = "SpeechRepeatActivity";//***enter your own tag here***
//TTS variables
//variable for checking TTS engine data on user device
private int MY_DATA_CHECK_CODE = 0;
//Text To Speech instance
private TextToSpeech repeatTTS;
Inside your “onCreate” method, your class should already be calling the superclass method and setting your main layout. If not, it should begin like this:
Code:
//call superclass
super.onCreate(savedInstanceState);
//set content view
setContentView(R.layout.main);
Next, still inside your “onCreate” method, retrieve a reference to the speech button and list we created, using their ID values:
Code:
//gain reference to speak button
Button speechBtn = (Button) findViewById(R.id.speech_btn);
//gain reference to word list
wordList = (ListView) findViewById(R.id.word_list);
The List View is an instance variable, accessible throughout the class. Now we need to find out whether the user device has speech recognition support:
Code:
//find out whether speech recognition is supported
PackageManager packManager = getPackageManager();
List<ResolveInfo> intActivities = packManager.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (intActivities.size() != 0) {
//speech recognition is supported - detect user button clicks
speechBtn.setOnClickListener(this);
}
else
{
//speech recognition not supported, disable button and output message
speechBtn.setEnabled(false);
Toast.makeText(this, "Oops - Speech recognition not supported!", Toast.LENGTH_LONG).show();
}
We query the environment to see if the Recognizer Intent is present. If it is, we instruct the app to listen for the user pressing the speech button. If speech recognition is not supported, we simply disable the button and output an informative message to the user.
Step 4: Listen for Speech Input​
Let’s setup the click listener for the speech button we’ve instructed the app to detect clicks for. Outside the “onCreate” method, but inside your Activity class declaration, add an “onClick” method as follows:
Code:
/**
* Called when the user presses the speak button
*/
public void onClick(View v) {
if (v.getId() == R.id.speech_btn) {
//listen for results
listenToSpeech();
}
}
Now implement the method we’ve called here after the “onClick” method:
Code:
/**
* Instruct the app to listen for user speech input
*/
private void listenToSpeech() {
//start the speech recognition intent passing required data
Intent listenIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//indicate package
listenIntent.putExtra(RecognizerIntent.EXTRA_CALLI NG_PACKAGE, getClass().getPackage().getName());
//message to display while listening
listenIntent.putExtra(RecognizerIntent.EXTRA_PROMP T, "Say a word!");
//set speech model
listenIntent.putExtra(RecognizerIntent.EXTRA_LANGU AGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//specify number of results to retrieve
listenIntent.putExtra(RecognizerIntent.EXTRA_MAX_R ESULTS, 10);
//start listening
startActivityForResult(listenIntent, VR_REQUEST);
}
Some of this code is standard for setting up the speech recognition listening functionality. Areas to pay particular attention to include the line in which we specify the “EXTRA_PROMPT” – you can alter this to include text you want to appear for prompting the user to speak. Also notice the “EXTRA_MAX_RESULTS” line, in which we specify how many suggestions we want the recognizer to return when the user speaks. Since we are calling the “startActivityForResult” method, we will handle the recognizer results in the “onActivityResult” method.
When the app is listening for user speech, it will appear as follows:
Step 5: Present Word Suggestions​
Implement the “onActivityResult” method inside your class declaration as follows:
Code:
/**
* onActivityResults handles:
* - retrieving results of speech recognition listening
* - retrieving result of TTS data check
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//check speech recognition result
if (requestCode == VR_REQUEST && resultCode == RESULT_OK)
{
//store the returned word list as an ArrayList
ArrayList<String> suggestedWords = data.getStringArrayListExtra(RecognizerIntent.EXTR A_RESULTS);
//set the retrieved list to display in the ListView using an ArrayAdapter
wordList.setAdapter(new ArrayAdapter<String> (this, R.layout.word, suggestedWords));
}
//tss code here
//call superclass method
super.onActivityResult(requestCode, resultCode, data);
}
Here we retrieve the result of the speech recognition process. Notice that the “if” statement checks to see if the request code is the variable we passed when calling “startActivityForResult”, in which case we know this method is being called as a result of the listening Intent. The recognizer returns the list of 10 suggested words, which we store as an Array List. We then populate the List View with these words, by setting an Array Adapter object as Adapter for the View. Now each of the items in the List View will display one of the suggested words.
If the app successfully recognizes the user input speech and returns the list of words, it will appear as follows:
Alternatively, if the app does not recognize the user speech input, the following screen will appear:
Step 6: Detect User Word Choices​
We want to detect the user selecting words from the list, so let’s implement a click listener for the list items. Back in your “onCreate” method, after the existing code, set the listener for each item in the list as follows:
Code:
//detect user clicks of suggested words
wordList.setOnItemClickListener(new OnItemClickListener() {
//click listener for items within list
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//cast the view
TextView wordView = (TextView)view;
//retrieve the chosen word
String wordChosen = (String) wordView.getText();
//output for debugging
Log.v(LOG_TAG, "chosen: "+wordChosen);
//output Toast message
Toast.makeText(SpeechRepeatActivity.this, "You said: "+wordChosen, Toast.LENGTH_SHORT).show();//**alter for your Activity name***
}
});
We use the “setOnItemClickListener” method to assign a listener to each item in the list. Inside the new “OnItemClickListener”, we implement the “onItemClick” method to respond to these clicks – this method will fire when the user selects a suggested word from the list. First, we cast the View that has been clicked to a Text View, then we retrieve the text from it. This text is the word the user has selected. We write the chosen word out to the Log for testing and output it back to the user as a Toast message. Depending on the needs of your own application, you may wish to carry out further processing on the chosen word – this code is purely for demonstration.
The user can press the touchscreen or use a trackball to select words in the list.
When the user selects a word, the Toast message appears confirming it.
Step 7: Setup TTS Functionality​
If you do not want to implement the Text To Speech functionality, you can stop now and test your app. We only require a little more processing to make our app repeat the user’s chosen word. First, to set up the TTS engine, add the following code to the section in your “onCreate” method where you queried the system for speech recognition support. Inside the “if” statement, after “speechBtn.setOnClickListener(this);”:
Code:
//prepare the TTS to repeat chosen words
Intent checkTTSIntent = new Intent();
//check TTS data
checkTTSIntent.setAction(TextToSpeech.Engine.ACTIO N_CHECK_TTS_DATA);
//start the checking Intent - will retrieve result in onActivityResult
startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE);
Like the speech listening process, we will receive the result of this code checking for TTS data in the “onActivityResult” method. In that method, before the line in which we call the superclass “onActivityResult” method, add the following:
Code:
//returned from TTS data check
if (requestCode == MY_DATA_CHECK_CODE)
{
//we have the data - create a TTS instance
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
repeatTTS = new TextToSpeech(this, this);
//data not installed, prompt the user to install it
else
{
//intent will take user to TTS download page in Google Play
Intent installTTSIntent = new Intent();
installTTSIntent.setAction(TextToSpeech.Engine.ACT ION_INSTALL_TTS_DATA);
startActivity(installTTSIntent);
}
}
Here we initialize the TTS if the data is already installed, otherwise we prompt the user to install it. For additional guidance on using the TTS engine, see the Android SDK: Using the Text to Speech Engine tutorial.
To complete TTS setup, add the “onInit” method to your class declaration, handling initialization of the TTS as follows:
Code:
/**
* onInit fires when TTS initializes
*/
public void onInit(int initStatus) {
//if successful, set locale
if (initStatus == TextToSpeech.SUCCESS)
repeatTTS.setLanguage(Locale.UK);//***choose your own locale here***
}
Here we simply set the Locale for the TTS, but you can carry out other setup tasks if you like.
Step 8: Repeat the User Choice​
Finally, we can repeat the user’s chosen word. Back in your “onCreate” method, inside the “OnItemClickListener” “onItemClick” method, after the line in which we output a Toast message, add the following:
Code:
//speak the word using the TTS
repeatTTS.speak("You said: "+wordChosen, TextToSpeech.QUEUE_FLUSH, null);
This will cause the app to repeat the user’s chosen word as part of a simple phrase. This will occur at the same time the Toast message appears.
Conclusion
That’s our complete Speak and Repeat app. Test it on an Android device with speech recognition and TTS support – the emulator does not support speech recognition so you need to test this functionality on an actual device. The source code is attached, so you can check if you have everything in the right place. Of course, your own apps may implement speech recognition as part of other processing, but this tutorial should have equipped you with the essentials of supporting speech input.​
Android SDK Commands & Explanations
Adb has many built in commands. Some are interactive (meaning they keep running until you stop them) and some just perform a simple task. Below is a list of the commands in the 1.0 SDK version of adb.​
Android Debug Bridge version 1.0.20
Code:
-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
-s <serial number> - directs command to the USB device or emulator with
the given serial number
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> <local> - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-product - prints: <product-id>
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PDP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition
is updated.
Common Use:​
Some of the more common commands in adb are push, pull, shell, install, remount, and logcat.
Push sends a file from your desktop computer to your Android device:
Code:
adb push test.txt /sdcard/test.txt
Pull pulls a file from your Android device to your desktop computer:
Code:
adb pull /sdcard/test.txt test.txt
Shell lets you run an interactive shell (command prompt) on the Android device:
Code:
adb shell
Install lets you install an android APK file to your Android device:
Code:
adb install myapp.apk
Remount remounts the /system partition as writable (or readonly if it is already writeable):
Code:
adb remount
Logcat lets you view the devices debug logs in real time (must press control+c to exit):
Code:
adb logcat
Further Notes On This Subject
It's great to see guides like these. I think every device forum should have these stickied in their general section. We all have/had to start somewhere. Having nice guides with accurate up-to-date information is only going to benefit everyone, and makes learning and understanding much easier. Fact is, we're all here for the same reason, to capitalize on the potential our devices have, and enjoy them. So, thanks for putting this together. It might seem trivial to a lot of the more experienced people, but those who aren't will definitely appreciate it.
Thanks. This is helpful.
Sent from my MB865
Hey Apex great job on the guide
I just wish this was here the first time I installed the the android sdk
I'm sure it will be useful to alot of members
41rw4lk said:
I think every device forum should have these stickied in their general section.
Click to expand...
Click to collapse
+1
Sticky?
Speak only when it improves on your silence.
Sorry for OT, this is not for Atrix 2 but I have question :
I want to extract included kernel in CM9 Rom, it is inside boot.img file. I've used Android Kitchen for extracting, it's ok now. I had zImage file.
So now how can I build flash-able zip file for CWM ? Tried UpdateZipCreator program but it showed error (7) when flashing.
I just wanna test many difference kernels and then come back to original but no flashable CM9 kernel here on xda.
vinamilk said:
Sorry for OT, this is not for Atrix 2 but I have question :
I want to extract included kernel in CM9 Rom, it is inside boot.img file. I've used Android Kitchen for extracting, it's ok now. I had zImage file.
So now how can I build flash-able zip file for CWM ? Tried UpdateZipCreator program but it showed error (7) when flashing.
I just wanna test many difference kernels and then come back to original but no flashable CM9 kernel here on xda.
Click to expand...
Click to collapse
Okay, Jim will probably be the one to ask on this. I don't recall which device you have currently (viewing from my phone) but he's the one who wrote the kernel for CM9 on the SGS3. I'm assuming you want to run the CM9 rom with 'experimental' kernels, so I'd PM him and ask (Sorry Jim, lol) but I'm not the expert on kernels or Android Kitchen, least not as knowledgeable as I should be to give a suitable answer...
Sent from my SAMSUNG-SGH-I747 using xda premium
oh! thanks a lot! I am very happy to find this!
long long ago! I start to find this resourse :cyclops:
EXCELLENT! I don't know i didn't see this before. Maybe because i didn't have this phone in August i think.
But great, tomorrow i will see if i can combine one of my designs with this, and try to make an alpha app.
Good guide
Hit thnx for every help
I just wanted to obtain logcat but where to type adb logcat...I get this in sdk
luvk1412 said:
I just wanted to obtain logcat but where to type adb logcat...I get this in sdk
Click to expand...
Click to collapse
With the sdk.. go to android-sdk/tools/ folder and double-click monitor.bat - easiest/nicest way to watch the logs..
To set up adb to be used from the command prompt or terminal, make sure you set your environment variables (or your .bashrc in Linux) to the path of adb in the sdk (it's in platform-tools)..
For Windows (Win7 example): Go to Start> right-click Computer>Properties>Advanced System Settings>Environment Variables...
Look under System Variables to see if you somehow have the path to C:\android-sdk\platform-tools in there already (or your specific location - just don't use spaces in the folder names in your path). If not, click on PATH under System Variables and Edit it..
Add your path to adb.exe (C:\android-sdk\platform-tools, for exapmle) to the end of the string of paths there. You can also add the path to \android-sdk\tools for good measure..
Click OK.. "Revenge of the Fern" - inside joke...
For Linux (Ubuntu 12.04, for example): Go to your home folder, hit Ctrl+H, open the .bashrc, and add this (or your specific path) to the bottom:
Code:
# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
Then you should be able to open the command prompt or terminal and type: adb devices - and hopefully get your device id..
Then: adb logcat - for logcat (or just use the monitor.bat as mentioned above, it has a much nicer interface)
See my "Guide" on getting started in the Themes&Apps section for more adb stuff too..
Other alternatives for logcat directly on your phone are through Terminal Emulator (type su.. then logcat), or apps available on the Play Store (aLogcat, for example).
Hey I am just getting started with android dev. Have done just a few tutorials from the developers.android.com, so basically a noob at this. But I saw that Google recently launched the android studio for app developement. I was just getting started with eclipse, but the android studio looks more intuitive because of its better GUI. I'm bad at xml editing too So I think the interface of Android Studio would suit better. Is there anyone here who has tried both and knows the cons of abandoning eclipse IDE and going for Android Studio?
help
Hay friend i have downloaded Java JDK 6.0.45 & 6.0.07 & Java JRE 6,7 to But when i open eclips it shows me this error can you help me to get it solve
http://forum.xda-developers.com/showthread.php?t=2276871
http://forum.xda-developers.com/showthread.php?t=2227376&page=14
Do you know what path i use to upack the adt bundle i have unpacked it in almost every location on my computer and still nothing eclipes wont work nothing works plz let me know if you can help i really dont want to smash my new laptop that will be no2 in amonth if i do plz help

Copy text to clipboard in shell

Interacting with the Clipboard from the shell can be difficult.
It used to be easier and you could use service call clipboard ...
Nowadays Clipboard only takes ClipData.
Ok, you could still do it using the service executable but you'd have a long list of opaque numbers.
I wrote a regular executable (not using any Java itself) to fill the Clipboard with your text.
It works for UTF-8, although I haven't gotten it to work pretty-like on Windows.
(I got the CHCP 65001, but I don't have a font for the console.)
Code:
# /data/local/tmp/copyclip 'I want to go to 中关村科贸电子城.'
This is an ELF64, you have to be rooted, it's a beta and everything is subject to change.
It works on A10. Later Android might need some fixes for attribution tags.
You should rename it to plain "copyclip".
Just park it somewhere (/data/local/tmp is fine) and chmod 755 it.
I've made a few tiny tweaks.
You can do the paste automatically, but there's a rub.
The input keyevent is pretty stupid because it rolls out a whole zygote just to inject a key.
Still, if you don't expect performance you can always:
Code:
# ./copyclip 'The short tedious text' && input keyevent 279
Normally, I do either a USB HID device or a key injector daemon if I want performance.
As noted previously, copyclip itself doesn't roll out a zygote, so it's quick.
Edit: Update again March 7th.
Yet another fine tuning.
I'm thinking about -e processing like echo has.
copyclip can be found in my sig.
Hmm, that's interesting. There were big changes in ClipData from A10 to A11.
This wouldn't work if you are on A11.
There's a two new versions out that works for at least A9, A10 & A11, either 32 bit or 64 bit.
If you're not rooted you'll probably get:
Code:
Error: Package android does not belong to 2000
You'll find it in the sig.
I'd appreciate any feedback on success/failure.
It seems like this would be really useful for entering snippets of Unicode text selected from the desktop.
input text can't handle Unicode.
One of the reasons that I'm having fun with this is the efficiency of not using app_process/Zygote/Java.
Code:
Poke3:/ # time input text Hello
0m00.51s real 0m00.28s user 0m00.20s system
Poke3:/ # time /data/local/tmp/copyclip Hello
0m00.04s real 0m00.01s user 0m00.02s system
Yow! I love talking to myself! I'm 7 posts in and no interruptions from somebody who wants to know something.
I just posted (Win32) adbclip.exe, an amazing accessory that works in concert with (Android) copyclip.
If you're on your desktop you can go to some nice Korean (or Japanese or Arabic or English) website, select some text and then paste it to the Android clipboard!
Amazing, eh?
All the details are in my sig, or more directly: http://www.temblast.com/copyclip.htm.
The Android utility copyclip has been updated:
You can style the text bold with -b and/or italic with -i
You can pipe other shell commands to it: date | /data/local/tmp/copyclip

Categories

Resources