Tuesday, December 18, 2012

How to upgrade Android app in Google Play (Android Market)

Check this link
http://developer.appcelerator.com/question/20271/publish-an-application-upgrade-on-android-market-not-work

from above link

Go to your YourApp/build/android/ folder. Make a copy of your AndroidManifest.xml. Rename it to AndroidManifest.custom.xml.
Change following lines: android:versionCode="1" android:versionName="1"
to: android:versionCode="2" // A number higher than the one above android:versionName="1.1" // Version number to show
Leave both files and recompile and zipalign. This works with me.

Saturday, December 15, 2012

OAuth and REST in Android

RESTful Web Services and Google Maps integration with Android Application

How to read all .txt (Text File) from SD Card in Android



public class FindFilesFromSDCardRanjit extends Activity {
TextView tvFileList;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_files_from_sdcard);
tvFileList = (TextView) findViewById(R.id.textViewFiles);
FindFileNames_Path("\\sdcard");
}

public void FindFileNames_Path(String dir) {

File directory = new File(dir);

if (!directory.isDirectory()) {
System.out.println("No directory provided");
return;
}

// create a FilenameFilter and override its accept-method
FilenameFilter filefilter = new FilenameFilter() {

public boolean accept(File dir, String name) {
// if the file extension is .txt return true, else false
return name.endsWith(".txt");
}
};

String[] filenames = directory.list(filefilter);

for (String name : filenames) {
System.out.println(name);
tvFileList.setText(tvFileList.getText() + "\n" + name);
}
}
}


--------------------
Main xml file
--------------------
<RelativeLayout 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" >

    <TextView
        android:id="@+id/textViewFiles"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="List of files"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

Sunday, December 2, 2012

How to use intent in an adapter class in Android

We can easily use intent in an Adapter class.

// This is 2 line code
Intent i = new Intent(v.getContext(), DetailStores.class);
v.getContext().startActivity(i);

//Same code we can write in an single line
v.getContext().startActivity(new Intent(v.getContext(), DetailStores.class));