Monday, June 27, 2016

Source code to Implement push notification for Sending and Receive messages via GCM for Android Studio

GCM Model Diagram


Send a message using GCM HTTP connection server protocol:



  https://gcm-http.googleapis.com/gcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
    "to": "/topics/foo-bar",
    "data": {
      "message": "This is a GCM Topic Message!",
     }
  }
Handle a downstream message on an Android device:


  @Override
  public void onMessageReceived(String from, Bundle data) {
     String message = data.getString("message");
     Log.d(TAG, "From: " + from);
     Log.d(TAG, "Message: " + message);
     // Handle received message here.
  }

Thursday, June 23, 2016

How to send and receive data via JSON in Android API 23


Hello guyz,

I  think  this  code  will  help  you  when  you  develop  an  application in   API  23  or  above... 

Any  Queries   just  fill  the  form  on  the  right  side  of  my  blog  and  click  send....


try {
                    URL url1=new URL(url);
                JSONObject j = new JSONObject();
                    j.put("tag", "login");
                    j.put("username", "admin");
                    j.put("password", "admin");

                HttpURLConnection connection=null;
                connection=(HttpURLConnection)url1.openConnection();
                connection.setRequestMethod("POST");
                connection.setRequestProperty("Content-Type", "application/json");
                connection.setDoInput(true);
                connection.setDoOutput(true);
                connection.setConnectTimeout(30000);
                connection.setReadTimeout(25000);
                OutputStreamWriter wr=new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
                wr.write(j.toString());
                wr.flush();
                wr.close();
                    Log.d("Json in json.java", j.toString());
                is=connection.getInputStream();
                    Log.d("is in json.java",is.toString());
                }catch (Exception e){
                    e.printStackTrace();
                }

In  PHP  file  receive  Values  as  JSON Object...

$json = file_get_contents('php://input');
$obj = json_decode($json);
$tag=$obj->{'tag'};
$username=$obj->{'username'};

$password=$obj->{'password'};

Saturday, June 18, 2016

What is GCM( Google Cloud Messaging) ??? and Details of the GCM....

Google Cloud Messaging

Hello  guyz,

Now i'm studying about the GCM(Google Cloud Messaging)...

It is a 100% free service given by Google. 

The people who are all didn't hear the word GCM are thinking what it is...

I'll explain it.. it is used to send push notification...

You can store your message in google server... when the device registered in the google server via your app will come online... it will sync with the server and then it will receive message...

i think it may be helpful to you....

Saturday, June 11, 2016

How to Generate Notification in Android API level 23 (Marshmellow) for Android Studio


Notification
Hello guys,

When we develop an android app with target API level  23 means you can't create Notification like  in  API  below  23... For  that  you have  to  use  Notification.Builder......

On such situation you will use this coding to generate notification for your app...

It works for me and i'll hope that same for you.....

Code to  generate Notification:

Notification.Builder nb = new Notification.Builder(context);
        nb.setSmallIcon(android.R.drawable.stat_notify_more);
        nb.setContentTitle("Notification");
        nb.setContentText("Now Generated");
        nb.setTicker("New Notification");
        Intent i = new Intent(); /*if you want to start any activity by clicking the notification use it like a normal intent to call an activity*/
        i.putExtra("eid",eid);
        PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
        nb.setContentIntent(pi);
        Notification n = nb.getNotification();
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        nm.notify(0, n);

Thanks for view my Blog...

If you have any queries  leave it as a comment plz....

Backup of my carrier...... Web design is my another in my life...


Hello  guyz,

I  had  a  bad  habit  of  having  a  backup  for  everything( Except  life ).

Likewise  i  want  a  backup  plan  for  my  carrier...
so  i'm  confused  of  choosing  which  one  i  need... Because  our  computer  field  is  a  biggest  one....

Finally  i  had chosen it...

It  was  Web Design...

Yep... Today  is  the  first  day  i  had  step  into  this  field... 

Already  i  know  how  to  design  a  static  webpage... But  i  had  no  idea  about  the dynamic webpage... Now  i  got  it...

Now  i  have  two  open  source  platforms...

I  want  to  rock  with it  and  i'll......

Friday, June 10, 2016

My experience in Developing Mobile application for android


Hi  guyz,

Developing  an  app  in  an  android  platform  is  a  interesting  one for  me.  I  like  it because  it  was  my  first  field  in  my  carrier...

Day  by  day  i'm  facing  so  many  task  in  it.  It  helps  me  to  improve  my  skills  in  this  platform  and also  my  logical  thinking...

I  know  that  this  is  not  enough...  But  i  not  going  to  stop my  learning...

I  Don't  know  whether  you  know  it  or  not....  I'll  tell...

Everyone  can  able  to  write  a  code  to  solve  a  task/problem.  But  among  them  there  are  few  will  think  in  what  way  are  we  going  to  solve  that  task/problem...

I'm  the  one  in  that  few...  if   i'm   not  one  day   i'll...

Wednesday, June 8, 2016

My First Project in Android

Hello   Guys...

I'm  a  college  student.  I  had  my  interest  on  developing  application  for  smartphones.

I'm  working  in  a  platform  named  android  for  last  6  months.

Now  I'm  developing  an  app.

The  whole  Back-end  and  the  web  services   are   done   by   me   alone   and   my   Senior  as   well  as   my   bro  Mr.J R Naveen  (He  works  in  embedded)  helps   me   to  finish  the  Front-end   for   the   app.

we  will  host  this  app  in  google  play  store  in  next  month.

After  completing  the  app  i'll  give  the  detailed  info.