2012년 6월 18일 월요일

Start Google Map with address

String address = ""; // Enter address hear

Uri uri = Uri.parse("geo:0,0?q=" + Uri.encode(address)); // if address has special character like '#', it should be encoded.

Intent intent = new Intent(Intent.ACTION_VIEW, uri);

startActivity(intent);

2012년 6월 14일 목요일

Android Connection Check

public boolean isConnected() {

ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting();

}



AndroidManifest.xml

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

2012년 6월 7일 목요일

Admob을 화면 밑에 ListView를 나머지 공간에 배치하기

<?xml version="1.0" encoding="utf-8">

<RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

android:layout_width="match_parent"

android:layout_height="match_parent">


<com.google.ads.AdView

ads:adSize="BANNER"

ads:adUnitId="MY_AD_UNIT_ID"

ads:loadAdOnCreate="true"

android:id="@+id/adView"

android:layout_height="wrap_content"

android:layout_width="fill_parent"

android:layout_alignParentBottom="true" />


<ListView

android:id="@+id/list"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_above="@id/adView"/>


</RelativeLayout>