Skip to content

Instantly share code, notes, and snippets.

@Moddus
Last active January 1, 2016 00:19
Show Gist options
  • Save Moddus/8066191 to your computer and use it in GitHub Desktop.
Save Moddus/8066191 to your computer and use it in GitHub Desktop.
Some stuff i need for Android development

general:

am broadcast -a <Intent-Name> -n <Package>/<Receiver-Name-with-leading-dot> <Extras>

example:

am broadcast -a com.google.android.c2dm.intent.REGISTRATION -n de.example/.GCMBroadcastReceiver 
--es "registration_id" "1234"

explanation: --es define extra as string

full command:

adb shell am broadcast -a com.google.android.c2dm.intent.REGISTRATION 
-n de.example/.GCMBroadcastReceiver --es "registration_id" "1234"

testing:

uncomment android:permission="com.google.android.c2dm.permission.SEND" from your broadcast receiver configuration.

more details:

adb shell am help for more information.

general:

Sometimes you need data that are stored under /data/data/<your.package.name>. This location needs root access to read but not all your devices are rooted. So how to handle it ?

command:

shell@foo:/ $ run-as <your.package.name>
shell@foo:/data/data/<your.package.name> $ l
app_sslcache
cache
databases
files
lib
shared_prefs
shell@foo:/data/data/<your.package.name> $ chmod -R 777 databases/

Now you're ready to pull the local database:

adb pull /data/data/<ypur.package.name>/databases/<database.name>

notice:

There ist a bug in android 4.3 ticket 58373.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment