Wednesday, 20 January 2016

How to increase size of the Floating SubActionButton


   In previous post I explained how to create circular floating action menu .Now I am going to explain how to increase  the size of  floating SubActionButton in android.

                                                        


Step 1)  You can set LayoutParams in the SubactionButton

    LayoutParams params=new LayoutParams(80,80);
    button1.setLayoutParams(params);


Step 2) Import LayoutParams 


import com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.LayoutParams;


Happy Coding :)
       

Wednesday, 13 January 2016

Create Circular Floating Action Menu in Android.


                      Here I am going to explain how to create Circular Floating Action menu(FAB) in Android.

Step 1) activity_main.xml


<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    </android.support.design.widget.AppBarLayout>

   <android.support.design.widget.FloatingActionButton

        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>


//To increase the size of SubActionButton click here

                                    


Step 2)Mainactivity.class

import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionMenu;
import com.oguzdev.circularfloatingactionmenu.library.SubActionButton;


public class MainActivity extends AppCompatActivity
{

    private Toolbar toolbar;
   

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar= (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

       

        SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);
        
        ImageView item1 = new ImageView(this);
        item1.setImageResource(R.mipmap.ic_launcher);

        ImageView item2 = new ImageView(this);
        item2.setImageResource(R.mipmap.ic_launcher);

        ImageView item3 = new ImageView(this);
        item3.setImageResource(R.mipmap.ic_launcher);

        SubActionButton button1 = itemBuilder.setContentView(item1).build();
        SubActionButton button2 = itemBuilder.setContentView(item2).build();
        SubActionButton button3 = itemBuilder.setContentView(item3).build();


      
        //attach the sub buttons
         new FloatingActionMenu.Builder(this)
                .addSubActionView(button1)
                .addSubActionView(button2)
                .addSubActionView(button3)
                .attachTo(fab)
                .build();

  }

Step 3)build.gradle


apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.floatinglabel"
        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.android.support:design:23.0.1'

    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
}


Happy Coding :)



Monday, 11 January 2016

How to get the SHA1 fingerprint certificate in android



 Here I am going to explain how to get SHA1 fingerprint certificate in android


Step 1). Open your command prompt 

cd C:\Program Files\Java\jdk1.7.0_67\bin

Step 2)Now type in the below command in your cmd prompt 


keytool -exportcert -alias androiddebugkey -keystore "C:\Users\userName\.android\debug.keystore" -list -v 


and the base password is android


Happy Coding:)


Friday, 1 January 2016

Get Call Logs from android device


   Here I am going to explain how to call history from android device


Step 1)

  
         Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI,                                                                                       null, null, null, null);

        int number managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
        int type managedCursor.getColumnIndex(CallLog.Calls.TYPE);
        int date managedCursor.getColumnIndex(CallLog.Calls.DATE);
        int duration managedCursor.getColumnIndex(CallLog.Calls.DURATION);

        while (managedCursor.moveToNext()) {

            String phNumber = managedCursor.getString(number);
            String callType = managedCursor.getString(type);
            String callDate = managedCursor.getString(date);


            String callDuration = managedCursor.getString(duration);
            String dir = null;
            int dircode = Integer.parseInt(callType);
            switch (dircode) {
                case CallLog.Calls.OUTGOING_TYPE:
                    dir = "OUTGOING";
                    break;
                case CallLog.Calls.INCOMING_TYPE:
                    dir = "INCOMING";
                    break;
                case CallLog.Calls.MISSED_TYPE:
                    dir = "MISSED";
                    break;
            }

         
            Date callDayTime = null;
            if (callDate != null) {
                callDayTime = new Date(Long.valueOf(callDate));
            } else 
            {
             Log.e("date","");
            }


           Log.e("date",callDayTime.toString());
           Log.e("number",phNumber);
           Log.e("type",dir);
           Log.e("duration",callDuration);

        }


Step 2).Add below permission to your manifest file.

  <uses-permission android:name="android.permission.READ_CALL_LOG" />

 <uses-permission android:name="android.permission.READ_CONTACTS" />


Happy coding :)


    

Get Inbox messages from android device


   Here I am going to explain how to get list of messages from android

  Step 1)

       Uri uri = Uri.parse("content://sms");
        Cursor cursor = getContentResolver().query(uri, null, null, null, null);
        String body="",number="",date,type;
        Date  smsDayTime=null;
        String typeOfSMS = null;
        if (cursor.moveToFirst()) {
            for (int i = 0; i < cursor.getCount(); i++) {
                 body = cursor.getString
                             (cursor.getColumnIndexOrThrow("body")).toString();
                        
                 number=cursor.getString
                             (cursor.getColumnIndexOrThrow("address")) .toString();

                       
                 date = cursor.getString(cursor.getColumnIndexOrThrow("date"))
                                                                                              .toString();
                 smsDayTime = new Date(Long.valueOf(date));
                 type = cursor.getString(cursor.getColumnIndexOrThrow("type"))
                        .toString();

                switch (Integer.parseInt(type)) {
                    case 1:
                        typeOfSMS = "INBOX";
                        break;

                    case 2:
                        typeOfSMS = "SENT";
                        break;

                    case 3:
                        typeOfSMS = "DRAFT";
                        break;
                }


               
                Log.e("time",msDayTime.toString());
                Log.e("number",number);
                Log.e("type",typeOfSMS);
                Log.e("body",body);
               
                cursor.moveToNext();

            }



        }


        cursor.close();

    }


Step 2)Add SMS permission to your manifest file.

    <uses-permission android:name="android.permission.READ_SMS" />


Happy coding :)