Wednesday, August 8, 2012

Code for Previous most Activity directly with out re calling the Activity



Code for
FirstActivity   ---> SecondActivity  ---> ThirdActivity

backPress: Thied ---> Second --->  First

When you click the GoToMainActivity button in ThiredActivity it will directly go to MainActivity by finishing the SecondActivity also

MainActivity ;
--------------


public class MainActivity extends Activity {
private Button next;

public static boolean back = false;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        next = (Button) findViewById(R.id.next);
    next.setText("First");
    }
   
    public void nextActivity(View view){
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
}  
   
}


SecondActivity :
----------------

public class SecondActivity extends Activity {
private Button next;

public static boolean back = false;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        next = (Button) findViewById(R.id.next);
        next.setText("Second");
    }
   
    public void nextActivity(View view){    
Intent intent = new Intent(SecondActivity.this, ThirdActivity.class);
startActivity(intent);
}
   
@Override
    public void onResume(){
        super.onResume();
        /*
         * check the cundition wether user click the recomencer button if click colose this activity else resume the activity
         */
       
        if(back!= false){      
back();
}
    }
   
    public void GoBack(View view){
back();
}
/*
* this ethode is usefull to finish this activity when click recomencer button click
*/
public void back(){
finish();
back = false;
}
   
}



ThirdActivity ;
--------------


public class ThirdActivity extends Activity {
private Button next;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        next = (Button) findViewById(R.id.next);
    next.setText("Go to MainActivity");
    }
   
    public void nextActivity(View view){
    SecondActivity.back = true;
    finish();
}  
   
}

main.xml:
----------


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp" >
    <Button
        android:id="@+id/next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:onClick="nextActivity"
        android:text="first" />

</RelativeLayout>







Wednesday, May 30, 2012

How to play embed you tube video in web view

How to play embed you tube video in web view  

Note: this is applicable in HTML-5 browser supported devices only 

myWebView = (WebView) findViewById( R.id.webview_compontent );

String playVideo= "<html><body>Youtube video .. <br> <iframe class=\"youtube-player\" type=\"text/html\" width=\"640\" height=\"385\" src=\"http://www.youtube.com/embed/bIPcobKMB94\" frameborder=\"0\"></body></html>"

myWebView.loadData(playVideo, "text/html", "utf-8");

Saturday, May 26, 2012

30 helpful Android development Tips/Tricks


30 helpful Android development Tips/Tricks


Hello All,

  1. #AndroidDev #AndroidTip: To resolve this issue “Failed to install *.apk on device timeout Launch canceled! , increase ADB connection timeout
  2. #AndroidDev #AndroidTip: use setError() to display error message for your EditText
  3. #AndroidDev #AndroidTip => To Block the default animation for startActivity() For ex: myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  4. #AndroidDev #AndroidTip: Android Action Bar Style Generator http://jgilfelt.github.com/android-actionbarstylegenerator
  5. #AndroidDev #AndroidTip create library with reusable code and reference it in future projects.
  6. #AndroidDev #Tip #PureAndroid Don’t use right-pointing carets on line items http://developer.android.com/design/media/migrating_ios_settings.png
  7. #AndroidTip #AndroidDev 10 amazing Android development tips http://www.netmagazine.com/features/10-amazing-android-development-tips
  8. #AndroidDev #Tips => Define these attributes for displaying multiline EditText => android:singleLine=”false”, android:lines=”5″
  9. #AndroidDev #Tip => Follow Dashboard design pattern. Easy to implement and handle Navigation.
  10. #AndroidDev #Tip – Before starting with android app development, should read Android Building Blocks http://developer.android.com/design/building-blocks/index.html
  11. #AndroidDev #Tip => You can create your custom views by extending View class.
  12. #AndroidDev #Tip use android:weight=”1″ and android:layout_width=”0″ to define equal width of widgets inside LinearLayout.
  13. #AndroidDev #Tip => With Android 4.0 you cant use http connection or make web call without using a Thread (with a runnable, AsyncTask )
  14. #AndroidDev #Tips: Tutorial , Tips/Trick for Android http://stackoverflow.com/questions/3405695/tutorial-tips-trick-for-android
  15. AndroidDev #Java #Tip What should be the package name of android app? http://stackoverflow.com/questions/8075162/what-should-be-the-package-name-of-android-app
  16. #AndroidDev #Tip: GraphView Library for Android to programmatically create flexible and nice-looking diagramms http://www.jjoe64.com/p/graphview-library.html?spref=tw
  17. #AndroidDev #Tip => how to limit seekbar http://stackoverflow.com/questions/3490951/how-to-limit-seekbar
  18. #AndroidDev: Do you know? => Android: maximum length of url http://stackoverflow.com/questions/10172566/android-maximum-length-of-url
  19. #AndroidDev #Tips => RT @piyushnp How To Create a Android App With ICS UI That Works With Gingerbread and Froyo? http://stackoverflow.com/questions/9886523/how-to-create-a-android-app-with-ics-ui-that-works-with-gingerbread-and-froyo
  20. #AndroidDev #Tip – Switch widget is available from API 14 http://developer.android.com/reference/android/widget/Switch.html
  21. #AndroidDev #Tip – How to design tab icons? http://developer.android.com/guide/practices/ui_guidelines/icon_design_tab.html
  22. #AndroidDev rating bar padding problem http://code.google.com/p/android/issues/detail?id=2324
  23. #AndroidDev Anyone ever seen this exception when loading bitmaps in Android?… http://developer.android.com/training/displaying-bitmaps/index.html #BitmapVMSizeExceed
  24. #AndroidDev #Tip : To capture screen shot from real android device, simply Press Home button + Back key
  25. #AndroidDev #Tip : use android:installLocation=”auto” to enable move to SD-card feature for Android app http://www.technotalkative.com/android-enable-the-move-to-sd-card-feature/
  26. #AndroidDev #Tip : Use SimpleDateFormat class to change format of date/time.
  27. #AndroidDev #Tip: How to view the SQLite database on your Android Emulator http://blog.kwyps.com/2011/07/how-to-view-sqlite-database-on-your.html
  28. #AndroidDev #Tip: you can check the status of AsyncTask by using getStatus() method, or like AsyncTask.Status.FINISHED
  29. #Android tip: Stop developing countdown algorithms, use the built-in CountDownTimer (http://developer.android.com/reference/android/os/CountDownTimer.html). #android #androiddev
please share your feedbacks/reviews