<commit_before>title: Android and Java Cheat Sheet
date: 2014-01-14 16:34:36
tags: android, java
---
+   Components of android
    *   Activities -email client
    *   Services -music player
    *   Content Providers - Note taking app or contacts
    *   Broadcast Receiver -The intent deliverer

open and visit website via intent
```java
adb shell am start -a android.intent.action.VIEW -d http://www.stackoverflow.com
```
Build from commandline an android project (replace 'Hello with name of Project')

```shell
android update project --name Hello --path
```

Use Environment Variables versus a sample or config file
```shell
export VARIABLE_NAME="VALUE"
export MIRROR_DEMO_CLIENT_ID="your app's id"
export MIRROR_DEMO_CLIENT_SECRET="your app's secret"
export MIRROR_DEMO_REDIRECT_URL="your redirect url"
```

in your code
```javascript
var oauth2Client = new OAuth2Client(process.env.MIRROR_DEMO_CLIENT_ID,
    process.env.MIRROR_DEMO_CLIENT_SECRET, process.env.MIRROR_DEMO_REDIRECT_URL);
```


Run an application from adb
```android

#example running setting

adb shell am start -a android.intent.action.Main -n com.android.settings/.Settings
```

Diagram
+ Intent Life Cycle
+ Services Life Cycle
+ Activity Life Cycle

Always Check the manifest for all related infomration

run the app, replace the latter with the activity you want to invoke
---
adb shell am start -n com.google.zxing.client.android/.CaptureActivity

Jars are just zips
-----
Use a utility like JD-GUI or Jad to unzip a jar and get the source. Perfect for when you lose the source or when you want to tinker.


``` shell

jar -xf YOURJAR.jar && find . -iname "*.class" | xargs ./jad -r
#cd into the directory and
mv *.jad *.java
```
Check out http://stackoverflow.com/questions/5107187/extract-source-code-from-jar-file/5107213#5107213


Having Camera Issues? Check Android manifest to make sure permissions are enabled
```xml
    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature android:name="android.hardware.camera" />
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />
```
<commit_msg>misspelled information<commit_after>title: Android and Java Cheat Sheet
date: 2014-01-14 16:34:36
tags: android, java
---
+   Components of android
    *   Activities -email client
    *   Services -music player
    *   Content Providers - Note taking app or contacts
    *   Broadcast Receiver -The intent deliverer

open and visit website via intent
```java
adb shell am start -a android.intent.action.VIEW -d http://www.stackoverflow.com
```
Build from commandline an android project (replace 'Hello with name of Project')

```shell
android update project --name Hello --path
```

Use Environment Variables versus a sample or config file
```shell
export VARIABLE_NAME="VALUE"
export MIRROR_DEMO_CLIENT_ID="your app's id"
export MIRROR_DEMO_CLIENT_SECRET="your app's secret"
export MIRROR_DEMO_REDIRECT_URL="your redirect url"
```

in your code
```javascript
var oauth2Client = new OAuth2Client(process.env.MIRROR_DEMO_CLIENT_ID,
    process.env.MIRROR_DEMO_CLIENT_SECRET, process.env.MIRROR_DEMO_REDIRECT_URL);
```


Run an application from adb
```android

#example running setting

adb shell am start -a android.intent.action.Main -n com.android.settings/.Settings
```

Diagram
+ Intent Life Cycle
+ Services Life Cycle
+ Activity Life Cycle

Always Check the manifest for all related information

run the app, replace the latter with the activity you want to invoke
---
adb shell am start -n com.google.zxing.client.android/.CaptureActivity

Jars are just zips
-----
Use a utility like JD-GUI or Jad to unzip a jar and get the source. Perfect for when you lose the source or when you want to tinker.


``` shell

jar -xf YOURJAR.jar && find . -iname "*.class" | xargs ./jad -r
#cd into the directory and
mv *.jad *.java
```
Check out http://stackoverflow.com/questions/5107187/extract-source-code-from-jar-file/5107213#5107213


Having Camera Issues? Check Android manifest to make sure permissions are enabled
```xml
    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature android:name="android.hardware.camera" />
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />
```

{'fraction_non_alphanumeric': 0.09649329253942104, 'fraction_numerical': 0.019298658507884207, 'mean_word_length': 4.145278450363196, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2387966', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1299, 'n_words': 455}