Saturday, 24 February 2018

Important Library for Android

Using Parceler


Although creating Android Parcelables is usually at least 10x faster than using Serializable, creating Parcelable objects requires creating a lot of boilerplate code in defining exactly the stream of data that should be serialized and deserialized as documented in this section.

https://github.com/codepath/android_guides/wiki/Using-Parceler



---------------------------------------------------------------------------------




Reducing View Boilerplate with Butterknife


Butterknife is a popular View "injection" library for Android. This means that the library writes common boilerplate view code for you based on annotations to save you time and significantly reduce the lines of boilerplate code written.


Android Plugin
-----Android ButterKnifeZelezny----



https://github.com/codepath/android_guides/wiki/Reducing-View-Boilerplate-with-Butterknife

Wednesday, 29 November 2017

All Size design scalable size unit






An android SDK that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.
for text views please refer to ssp which is based on the sp size unit for texts.

dependencies {
  compile 'com.intuit.sdp:sdp-android:1.0.5'
}

Wednesday, 15 November 2017

Device ID







final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();


Log.e(TAG,"deviceId........."+deviceId);

Wednesday, 8 November 2017

Data Send in android



integer data send from activity to service

-------------Activity--------------

Intent serviceIntent = new Intent(this, StatusService.class);
serviceIntent.putExtra("QB_Friend_Id",QB_Friend_Id);
startService(serviceIntent);



----------------service-------------------


@Overridepublic int onStartCommand(Intent intent, int flags, int startId) {
    // Let it continue running until it is stopped.
    if (intent != null && intent.getExtras() != null) {
        userID = intent.getIntExtra("QB_Friend_Id", 0);
        Log.v(TAG, "number........." + userID);
    }


Tuesday, 17 October 2017

Circular Floating Action Menu (FAB) Android



----------------------------gradle(build.gradle)------------------------------


apply plugin: 'com.android.application'
 
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
 
    defaultConfig {
        applicationId "com.galaxystech.fabdemo"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
 
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
 
}
 
 
 
 
 
-----------------activity_main.xml------------------------------------
 
 
 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
 
    <TextView
        android:text="@string/hello_world"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
 
</RelativeLayout>
 
 
 
 
--------------------------------MainActivity.java----------------------
 
 
 

package com.galaxystech.fabdemo;
 
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
 
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton;
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionMenu;
import com.oguzdev.circularfloatingactionmenu.library.SubActionButton;
 
public class MainActivity extends AppCompatActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        // Create an icon
        ImageView icon = new ImageView(this);
        icon.setImageResource(R.mipmap.ic_launcher);
 
        FloatingActionButton actionButton = new FloatingActionButton.Builder(this)
                .setContentView(icon)
                .build();
        SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);
        // repeat many times:
        ImageView itemIcon1 = new ImageView(this);
        itemIcon1.setImageResource(R.mipmap.ic_launcher);
 
        ImageView itemIcon2 = new ImageView(this);
        itemIcon2.setImageResource(R.mipmap.ic_launcher);
 
        ImageView itemIcon3 = new ImageView(this);
        itemIcon3.setImageResource(R.mipmap.ic_launcher);
 
        SubActionButton button1 = itemBuilder.setContentView(itemIcon1).build();
        SubActionButton button2 = itemBuilder.setContentView(itemIcon2).build();
        SubActionButton button3 = itemBuilder.setContentView(itemIcon3).build();
 
        //attach the sub buttons to the main button
        FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this)
                .addSubActionView(button1)
                .addSubActionView(button2)
                .addSubActionView(button3)
                .attachTo(actionButton)
                .build();
    }
}
 

Sunday, 15 October 2017

Navigation Drawer header on click Edit Profile






NavigationView navigationView = (NavigationView) findViewById(R.id.id_nav_std_view);
navigationView.setNavigationItemSelectedListener(this);
View headerview=navigationView.getHeaderView(0);
        txtview_edit =(TextView)headerview.findViewById(R.id.id_txt_edit_std_profile);

txtview_edit.setOnClickListener(new View.OnClickListener() {
    @Override    public void onClick(View v) {
        Intent intent = new Intent(StudentNavigation.this,EditStudentProfileActivity.class);
        startActivity(intent);
    }
});

Saturday, 7 October 2017

Current Date Time

 




  Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
                String strDate = sdf.format(c.getTime());


---------------------------------for compare------------------------------



try{

     SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");


     String str1 = "12/10/2013";
     Date date1 = formatter.parse(str1);

     String str2 = "13/10/2013";
     Date date2 = formatter.parse(str2);

     if (date1.compareTo(date2)<0)
      {
         System.out.println("date2 is Greater than my date1");                         
      }

    }catch (ParseException e1){
        e1.printStackTrace();
    }

AutoComplete Address (Updated)

-------------------------------------Activity---------------------------------- package placeautocomplete.iteritory.com; import androi...