Bluetooth .apk File Transfer Failed on android device

recently i try to send a .apk file to my android, but it constantly show internal error (i have paired it with my computer).

but after i changed the extension file into .zip it work flawlessly.

i think it is a security method in android. but many user including me doesn’t aware it.

Tinggalkan sebuah Komentar

Filed under Android, Programming

Darrell Royal Letter

You should all ask yourself what do you feel when you are defeated.

are you blaming others, feeling depressed, or are you feel with passion, ready to take the challenge again.

all those of you who has played on the field will have tasted defeat, there’s no player who has not lost before,

however the best players, as a tribute to all their efforts, will give everything they’ve got to stand up again,

the ordinary players will take them a while to get back on their feet,

while the losers will remain flat on the field. Do not be ashamed about being defeated

.to be defeated and to not stand up is what you should be ashamed of.

Tinggalkan sebuah Komentar

Filed under Curhatan

Apa sih maksud disclosure di DailySocial

Situs yang saya sering kunjungi yaitu dailysocial. pada akhir pemberitaan mengenai kaskus sengaja ditampilkan disclosure sebagai berikut :

  • disclosure : DS dan Kaskus berada di bawah induk perusahaan yang sama (link).
  • Disclosure: DailySocial diinkubasi oleh Merah Putih Inc. dan merupakan bagian dari GDP yang memberikan inventasi pada Kaskus (link).

Apa sih maksudnya nulisin yang gituan? kok jadinya sengaja memberitahu kalau ada peluang ketidakobjektifitasan dari pemberitaan mereka. who knows?
tapi opini saya sih (hanya firasat, tidak ada fakta, tanpa ada niatan jahat), kayanya ada deh ketidakobjektifitas. rasanya artikelnya ga pedes.

2 Komentar

Filed under Curhatan

Show keyboard when Activity start

i am currently working on a Search Activity, and i need to show the keyboard when this activity is started, and focus to the EditText. and to perform this task its simple just use this code

EditText keywordEdit = (EditText) findViewById(R.id.keywordEdit);
keywordEdit.setFocusable(true);
keywordEdit.requestFocus();

InputMethodManager imm = (InputMethodManager) SearchActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);

if(imm != null){ 
	imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); 
}

hopefully it helps

Tinggalkan sebuah Komentar

Filed under Android, Java, Programming

Android Draw Location Accuracy Radius

to get the accuracy in fix meter just use

float accuracy = lm.getLastKnownLocation(best).getAccuracy();

* note: best is an Criteria object

and to draw the Radius, just use this Overlay class, which extend an Overlay Class, and then add it to a MapOverlay

package com.bopbi.component;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Paint.Style;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class SourceOverlay extends Overlay {

	private GeoPoint sourcePoint;
	private float accuracy;

	public SourceOverlay() {
		super();
	}

	public void setSource(GeoPoint geoPoint, float accuracy) {
		sourcePoint = geoPoint;
		this.accuracy = accuracy;
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		super.draw(canvas, mapView, false);
		Projection projection = mapView.getProjection();
		Point center = new Point();

		int radius = (int) (projection.metersToEquatorPixels(accuracy));
		projection.toPixels(sourcePoint, center);

		Paint accuracyPaint = new Paint();
		accuracyPaint.setAntiAlias(true);
		accuracyPaint.setStrokeWidth(2.0f);
		accuracyPaint.setColor(0xff6666ff);
		accuracyPaint.setStyle(Style.STROKE);

		canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

		accuracyPaint.setColor(0x186666ff);
		accuracyPaint.setStyle(Style.FILL);
		canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

	}

}


* note: dont forget to use the setSource() method, before add it to a MapOverlay

Tinggalkan sebuah Komentar

Filed under Android, Java, Programming

Change Android ProgressBar Animation

To change a indeterminate progressbar style animation, simply use this drawable below, and rename it as progress_indeterminate.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
      <rotate android:pivotX="50%" android:pivotY="50%"
         android:fromDegrees="0" android:toDegrees="360"
         android:drawable="@drawable/progress_circular_indeterminate" />
   </item>
</layer-list>

* note the @drawable/progress_circular_indeterminate is pointing to your image file, you can change the name
To apply the Animation simply use this tag in the progress bar

android:indeterminateDrawable="@drawable/progress_indeterminate"

Based on this link about progress dialog and other animation

Tinggalkan sebuah Komentar

Filed under Android, Programming

Android Json Processing using GSON and Display in on a ListView

This is my way to process a json request using GSON library and display it on a ListView

Connect to a WebService

the code i used to interact with the web service is based on this blog http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

First, download GSON library in here

Format JSON Response

the json response format which we are going to response is like this:

{"locations":[{"name":"test","description":"testse","latlng":[12.0,13.0]},{"name":"gfd","description":"hh","latlng":[15.0,16.0]},{"name":"rumah bagas","description":"iki rumahe bagas","latlng":[0.0,20.0]}]}

the Model

in the json response show that it has a locations that consist on many location.

The LocationModel.java is the basic data from the json response:

package com.bopbi.model;

public class LocationModel {
	private String name;
	private String description;
	private float[] latlng;

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}

	public float[] getLatlng() {
		return latlng;
	}
	public void setLatlng(float[] latlng) {
		this.latlng = latlng;
	}
}

and the LocationList.java which the container for the LocationModel:

package com.bopbi.model;

import java.util.List;

public class LocationList {
    private List locations;

    public List getLocations() {
        return locations;
    }
    public void setLocationList(List locations) {
        this.locations = locations;
    }
}

LocationAdapter.java is the adapter that will be use to display the LocationList in a ListView is extends from an ArrayAdapter:

package com.bopbi.model;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.bopbi.R;

public class LocationAdapter extends ArrayAdapter {

	int resource;
	String response;
    Context context;
    private LayoutInflater mInflater;

	public LocationAdapter(Context context, int resource, List objects) {
		super(context, resource, objects);
		this.resource = resource;
		mInflater = LayoutInflater.from(context);
	}

	static class ViewHolder {
		TextView title;
		TextView description;
	}

	public View getView(int position, View convertView, ViewGroup parent)
    {
		ViewHolder holder;
        //Get the current location object
        LocationModel lm = (LocationModel) getItem(position);

        //Inflate the view
        if(convertView==null)
        {
            convertView = mInflater.inflate(R.layout.item, null);
			holder = new ViewHolder();
			holder.title = (TextView) convertView
					.findViewById(R.id.it_location_title);
			holder.description = (TextView) convertView
					.findViewById(R.id.it_location_description);

			convertView.setTag(holder);

        }
        else
        {
        	holder = (ViewHolder) convertView.getTag();
        }

        holder.title.setText(lm.getName());
		holder.description.setText(lm.getDescription());

		return convertView;
    }

}

and here is the main file, that later will be use to call the webservice using AsyncTask and display in onn a ListView

package com.bopbi.ui;

import java.util.ArrayList;

import com.bopbi.R;
import com.bopbi.model.LocationAdapter;
import com.bopbi.model.LocationList;
import com.bopbi.model.LocationModel;
import com.bopbi.util.RestClient;
import com.bopbi.util.RestClient.RequestMethod;
import com.google.gson.Gson;

import android.app.Activity;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

public class ListRest extends Activity {
	LocationManager lm;

	ArrayList locationArray = null;
	LocationAdapter locationAdapter;
	LocationList list;

	ListView lv;
	TextView loadingText;

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        lv = (ListView) findViewById(R.id.list_nearme);

        locationArray = new ArrayList();
        locationAdapter = new LocationAdapter(ListRest.this, R.layout.item, locationArray);

        lv.setTextFilterEnabled(true);
		lv.setAdapter(locationAdapter);

		try {
			new LocationSync().execute("http://vivid-snow-43.heroku.com/nearme.json");
		} catch(Exception e) {}
    }

	private class LocationSync extends AsyncTask {

		protected LocationList doInBackground(String... urls) {
			LocationList list = null;
			int count = urls.length;

	        for (int i = 0; i < count; i++) {
	        	try {

	    			RestClient client = new RestClient(urls[i]);

	    			try {
	    			    client.Execute(RequestMethod.GET);
	    			} catch (Exception e) {
	    			    e.printStackTrace();
	    			}

	    			String json = client.getResponse();

	    			list = new Gson().fromJson(json, LocationList.class);

	    		} catch(Exception e) {}
	        }
	        return list;
		}

		protected void onProgressUpdate(Integer... progress) {

	    }

	    protected void onPostExecute(LocationList loclist) {

	    	for(LocationModel lm : loclist.getLocations())
	        {
				locationArray.add(lm);
	        }
	        locationAdapter.notifyDataSetChanged();
	    }

	}
}

Layout File

the layout file is here, main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<TextView android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:text="Near Me" />
	<ListView android:id="@+id/list_nearme" android:divider="#FFCC00"
		android:dividerHeight="1dp" android:layout_width="fill_parent"
		android:layout_height="wrap_content"/>
</LinearLayout>

and the item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <TextView android:id="@+id/it_location_title" android:layout_width="wrap_content"
		android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp"
		android:textSize="20sp">
	</TextView>
	<TextView android:id="@+id/it_location_description" android:layout_width="wrap_content"
		android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp"
		android:textSize="14sp">
	</TextView>
</LinearLayout>

the complete source code

 

20 Komentar

Filed under Curhatan

Android Dial / Call

To Perform dial just use this intent :

Intent dialIntent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:021313"));

To Call, use below :
Intent dialIntent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:021313"));

but to use the call feature dont forget to add user-permission below
<uses-permission android:name="android.permission.CALL_PHONE">

Tinggalkan sebuah Komentar

Filed under Android, Java, Programming

Simple Progress Dialog Example

ProgressDialog dialog = ProgressDialog.show(ExampleApp.this, "","Please wait for few seconds...", true);

it will display something like this:

 

and to end it just use:

dialog.dismiss();

Tinggalkan sebuah Komentar

Filed under Android, Java, Programming

Change Title Bar in Android

Simply use

setTitle("Custom title");

Tinggalkan sebuah Komentar

Filed under Android, Java