Friday, March 6, 2015

Softcard google vs Apple payment

Kita sudah tidak terkejut lagi sekarang dengan adanya mobile payment atau mobile pocket. Satu lagi produk payment yang turus berkembang yaitu Softcard. Softcard saat ini sudah terintegrasi dengan google wallet dimana kalau bawa nama besar google aplikasi lain pasti akan terus menanjak menghancurkan kepopuleran aplikasi payment lain. Di official website softcard mereka mengatakan :

"Important news! We are pleased to let you know that Google has acquired technology from Softcard to power the next generation of mobile wallets.

What does this mean for you? As of 3/31 your Softcard app will no longer work. You can continue to use the Softcard app until 3/31. After that your Account will be closed.

To keep using a digital wallet app download Google Wallet now."

Hal ini akan menandakan akan adanya persaingan besar nantinya antara aplikasi payment milik google dan payment milik apple yang sudah rilis oktober lalu. Ada kemungkinan aplikasi Softcard milik google akan mengalahkan aplikasi milik apple karena jumlah aplikais android lebih besar dari jumlah pemakai apple. 









Selamat meninggalkan payment yang memerlukan banyak kartu dan selamat datang di z generation.


References 

SMH

Wednesday, March 4, 2015

Menggunakan Calendar Provider API Android

Calendar Provider API biasanya digunakan untuk membuat event. Menggunakan Calendar Provider API kita dapat membuat, mengubah dan menghapus event. Yang akan dibuat kali ini hanya create event saja.

1. XML Layout
Buat dua XML layout file di folder “res/layout/” :

res/layout/activity_main.xml tombol untuk membuat event

File : activity_main.xml
<LinearLayout 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"
    android:orientation="vertical" >"

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClick"
        android:text="Create Event" />

</LinearLayout>

2. Activity
Buat sebuah activity class.

1. MainActivity.java

File : MainActivity.java
package com.example.calendarapi;

import java.util.GregorianCalendar;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity {
    
 private static final String TAG = "MainActivity";
 
    public static final String[] EVENT_PROJECTION = new String[] {
  Calendars._ID,      // 0
  Calendars.ACCOUNT_NAME,   // 1
  Calendars.CALENDAR_DISPLAY_NAME // 2
    };
  private static final int PROJECTION_ID_INDEX = 0;
  private static final int PROJECTION_ACCOUNT_NAME_INDEX = 1;
  private static final int PROJECTION_DISPLAY_NAME_INDEX = 2;

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
  
  public void onClick(View view) {
  Intent intent = new Intent(Intent.ACTION_INSERT);
  intent.setType  ("vnd.android.cursor.item/event");
  intent.putExtra  (Events.TITLE, "Learn Android");
  intent.putExtra  (Events.EVENT_LOCATION, "Jakarta, Indonesia");
  intent.putExtra  (Events.DESCRIPTION, "");
  GregorianCalendar calDate = new GregorianCalendar();
  intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
    calDate.getTimeInMillis());
  intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
    calDate.getTimeInMillis());
  intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
  intent.putExtra(Events.RRULE,
    "FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH");
  intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
  intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
  startActivity(intent);
 }  

  public void queryCalendar(View view) {
  Cursor cursor = null;
  ContentResolver cr = getContentResolver();
  Uri uri = Calendars.CONTENT_URI;
  String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND ("
    + Calendars.ACCOUNT_TYPE + " = ?))";
  String[] 
    selectionArgs = new String[] { "sugarhutabarat@gmail.com",
    "com.google" };
  cursor = cr.query(uri, EVENT_PROJECTION, selection, selectionArgs, null);
  Toast.makeText(this, String.valueOf(cursor.getCount()), Toast.LENGTH_LONG)
    .show();
  
  while (cursor.moveToNext()) {
   long calID = 0;
   String displayName = null;
   String accountName = null;
   
   calID   = cursor.getLong(PROJECTION_ID_INDEX);
   displayName = cursor.getString(PROJECTION_DISPLAY_NAME_INDEX);
   accountName = cursor.getString(PROJECTION_ACCOUNT_NAME_INDEX);
   
   Toast.makeText(this, "Calendar " + displayName, Toast.LENGTH_SHORT)
     .show();
   
   long calID1 = 2;
   ContentValues 
   values = new ContentValues();
   values.put(Calendars.CALENDAR_DISPLAY_NAME, "Your Calendar Name");
   
   Uri updateUri = ContentUris.withAppendedId(Calendars.CONTENT_URI, calID1);
   int rows = getContentResolver().update(updateUri, values, null, null);
   Log.i(TAG, "Rows updated: " + rows);
  }
 }
}


Download Source Code
download source code disini dan cara download tusfile disini

References 


S.M.H

Sunday, March 1, 2015

Membuat Simple User Interface di Android

Untuk membuat simple user interface activity pada android pertama yang kita butuhkan adalah:

1. XML Layout
Buat dua XML layout file di folder “res/layout/” :

res/layout/activity_main.xml – Activity pertama

res/layout/displaymessage.xml – Activity kedua

File : res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="horizontal">
    <EditText 
        android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />
    <Button
        android:id="@+id/sendbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send"/>
</LinearLayout>
Kemudian kita tambahkan activity kedua untuk menampung teks dari activity pertama.

File : res/layout/displaymessage.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="113dp"/>

</RelativeLayout>
File : res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Send Message</string>
    <string name="edit_message">Write Message here</string>
    <string name="button_send">Send</string>
    <string name="action_settings">Settings</string>
    <string name="title_activity_main">MainActivity</string>
</resources>
2. Activity
buat 2 buah activity class

1. MainActivity.java
2. DisplayMessage.java

File : MainActivity.java
package com.example.simpleui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {
 
 protected static final String EXTRA_MESSAGE = 
   "com.example.simpleui.MESSAGE";
 
 public Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        onClickListener();
    }
    
    public void onClickListener(){
     final Context context = this;
     button = (Button)findViewById(R.id.sendbutton);
     button.setOnClickListener(new OnClickListener(){
   
   @Override
   public void onClick(View v) {
    Intent intent = 
      new Intent(context, DisplayMessage.class);
    EditText editText = 
      (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
   }
  });
    }


}

File : DisplayMessage.java
package com.example.simpleui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class DisplayMessage extends Activity{
 
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.displaymessage);
        onDisplayMessage();
    }
 public void onDisplayMessage(){
  
  Intent intent = getIntent();
  String message = 
    intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
  TextView textView = 
    (TextView) findViewById(R.id.message);
  textView.setTextSize(24);
     textView.setText(message);
 }
}

3. AndroidManifest.xml
deklarasikan class activity kedua pada AndroidManifest.xml

File : AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.simpleui"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".DisplayMessage"
            android:label="@string/app_name" >
        </activity>
    </application>

</manifest>

4. Demo
Running Aplikasi
Download Source Code
download source code disini dan cara download tusfile disini

References