Thursday, December 17, 2015

How to run Android App with latest Android tools


Google Android info

Android Styling:
 https://blog.stylingandroid.com/percent-part-1/

Install latest Android Studio:

Install latest Android emulator:

Enable Instant run:

Google Android tech docs:


Android developers blog
http://android-developers.blogspot.com/

Android best practices:
https://github.com/futurice/android-best-practices
 http://guides.codepath.com/android

Android devices Dashboard(google)
https://developer.android.com/about/dashboards/index.html


SourceTree uncommit
http://flummox-engineering.blogspot.com/2014/10/how-to-undo-git-commit-in-sourcetree.html

Wednesday, December 16, 2015

Butterknife Library for Android

Butterknife 

Is a view "injection" library for Android. It will reduces boilerplate code.

Example:
  1. Add dependency to app/build.gradle
dependencies {
  compile 'com.jakewharton:butterknife:7.0.1'
}
  1. In main.xml declare an image widget id name "image"
  2. In main.java start using @Bind to declare each variable 

public class Main extends AppCompatActivity {
private static final String ITENT_TAG= "chapter"; 

private Chapter chapter;

@Bind(R.id.button) Button myButton; 

@Bind(R.id.textTextView myText;

@Bind(R.id.image

ImageView myImage;  

@Override public void onCreate(Bundle savedInstanceState) 

{
super.onCreate(savedInstanceState);   setContentView(R.layout.activity_detail);   ButterKnife.bind(this); 

@OnClick(R.id.button) protected void Toast(){

Toast.makeText(getApplicationContext(),"Hello Android Butter Knife",Toast.LENGTH_LONG).show();}

}

myText.setText("Hello!");

res = getResources();
myImage.setImageDrawable(res.getDrawable(R.drawable.myimage));



  • Also initialize ButterKnife in OnCreate:
 ButterKnife.bind(this);


Resources:
http://www.sitepoint.com/tidying-code-with-android-butterknife/
https://guides.codepath.com/android/Reducing-View-Boilerplate-with-Butterknife

Sunday, December 13, 2015

Crashlytics for Android app

What is Crashlytics?

  • It's a great tool for developers; developer can get a lot of statics from the app... it's free.
  • Delivers crash reporting across devices in real-­time. 
  • Performs analysis of every thread on every Android device to identify the most important issues.
**Usage is super easy**

How to Setup:

  1. Register here https://get.fabric.io/
  2. In Android Studio install the Crashlytics plugin -Android Studio -> Preferences -> Plugins -> "Fabric plugin" Install 
  3. Now you will have the Fabric icon in Android Studio (image one below).
  4. Now select your app and enable Crashlytics, everything will be setup automatically just follow the instructions provided.
  5. Done. Build and install your App.
  6. Go to https://fabric.io/ to see the statistics of your app(image two below).
(image one)















(image two)





References:
http://www.crashlytics.com/blog/its-finally-here-announcing-crashlytics-for-android/
https://fabric.io/kits/android/crashlytics/summary

Great tutorial:
http://www.codedevplus.com/integrating-crashlytics-from-fabric-in-android/
https://fabric.io/kits/android/crashlytics/install

Saturday, December 12, 2015

Android and Parse (BAAS)

With Parse you can create apps and no worry to maintain a backend.
More info about parse: www.parse.com git: https://github.com/parseplatform

Getting started (Must do the below tutorial to understand how to setup Parse):
https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing 

https://www.parse.com/docs/android/guide#local-datastore

Great tutorial to save and retrieve data with Parse: http://www.sitepoint.com/creating-cloud-backend-android-app-using-parse/
github to above link: https://github.com/sitepoint-editors/Android-Parse

Todo app: http://blog.revivalx.com/2015/06/09/develop-a-simple-android-mobile-app-todolist-part-1/

Parse dashboard: https://dashboard.parse.com/apps

Login with Facebook: https://github.com/ParsePlatform/ParseFacebookUtils-Android
ex: https://parse.com/docs/android/guide#users-facebook-users

Login with Parse(save users in Parse backend for free): https://github.com/AndreSand/UserParse

Parse Store tutorial: https://github.com/ParsePlatform/ParseStore

Parse Android send notifications (easy setup): https://parse.com/apps/quickstart#parse_push/android/native/existing
https://parse.com/tutorials/android-push-notifications

SETUP:https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing 


.5 Create a test app in Parse dashboard to get AppID and ClientKey (found in: App Settings -> Security and keys)
1. Download the latest Parse.jar, and copy and paste to your app/lib/Parse.jar.
then add:
 dependencies {
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}
to /GradleScripts/build.graddle(app)

2. Now create a new directory ParseApp, here we are going to setup the parse app, Create class ParseSetup ( we will add this class to your Manifest).

public class ParseSetup extends Application {

    @Override    public void onCreate() {
        super.onCreate();
        Parse.enableLocalDatastore(this);
        Parse.initialize(this);        //setupParse();        ParseObject testObject = new ParseObject("TestObject");        testObject.put("foo", "bar222");        testObject.saveInBackground();

    }

}

3. Open AndroidManifest.xml and add the name of the Parse App class here (ParseSetup). ex:
<application    android:name=".ParseApp.ParseSetup"    android:allowBackup="true"    android:icon="@mipmap/ic_gamma"    android:label="@string/app_name"    android:supportsRtl="true"    android:theme="@style/AppTheme">    <activity android:name=".MainActivity">        <intent-filter>            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />        </intent-filter>    </activity>
    <meta-data        android:name="com.parse.APPLICATION_ID"        android:value="your_ID" />    <meta-data        android:name="com.parse.CLIENT_KEY"        android:value="your_key" />

also add the below Permissions:
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

test

Monday, December 7, 2015

Android M Runtime Permissions (info)

Great read:
http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en

ADB commands
Android 6.0 Permissions:
Granting and revoking runtime permissions:
$adb shell pm grant/revoke my.package.name some.permission.NAME

Installing an app with all permissions granted:
$adb install -g my.package.name

Dumping app permission state:
$adb shell dumpsys package my.package.name

Show all Android permissions:
$adb shell pm list permissions -d -g