Posts

Date 4/jul

  Asynctask -  Android AsyncTask is an abstract class provided by Android which gives us the liberty to perform heavy tasks in the background and keep the UI thread light thus making the application more responsive. ------------------------------------------------------------------------------------------------------------ The basic methods used in an android AsyncTask class are defined below : doInBackground() : This method contains the code which needs to be executed in background. In this method we can send results multiple times to the UI thread by publishProgress() method. To notify that the background processing has been completed we just need to use the return statements onPreExecute() : This method contains the code which is executed before the background processing starts onPostExecute() : This method is called after doInBackground method completes processing. Result from doInBackground is passed to this method onProgressUpdate() : This method receives progress upd...

AN IMPLICIT INTENT

Image
 Here we are gonna get through the  // Setting the intent Intent intent = new Intent(Intent. ACTION_VIEW , Uri. parse (data_earthquake.getmUrl())) ; intent.addFlags(Intent. FLAG_ACTIVITY_NEW_TASK ) ; intent.setPackage( "com.android.chrome" ) ; try { Log. d ( "debug" , "onClick: inTryBrowser" ) ; startActivity(intent) ; } catch (ActivityNotFoundException ex) { Log. e ( "debug" , "onClick: in inCatchBrowser" , ex ) ; intent.setPackage( null ) ; startActivity(Intent. createChooser (intent , "Select Browser" )) ; } here we are declaring the implicit intent and we are trying to open it in the chrome browser and in case if it is not installed in the phone then we get to select the browser. log.d -- is being used for the debug. we set the intent package to be null because we had already provided him the package so we need make it empty first. earthquakeListView.setOnItemClickListener( new AdapterView.OnItemClickLi...

UI folder

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="horizontal" android:layout_width="match_parent"     android:layout_height="match_parent" android:paddingEnd="16dp"     android:paddingLeft="16dp"     android:paddingRight="16dp"     android:paddingStart="16dp"     android:paddingTop="16dp"     android:paddingBottom="16dp">     <TextView         android:id="@+id/intensity"         android:layout_width="36dp"         android:layout_height="36dp"         android:layout_gravity="center_vertical"         android:background="@drawable/magnitude_circle"         android:fontFamily="sans-serif-medium"         android:gravity="center"         android:textColor="@android:color/white"     ...

UNIX TIME TO DATE FORMAT

Image

Errors

Image
* when we create a custom class in the studio remember the datatype     and keep an eye on them while declaring them in Adapter view     example- if its an String write this textplace.setText(currentposition.getMplace()) ; if its an double write this here we can see that we are converting the numerical value in a string before setting it as a view or it will give an error textintensity.setText(String. valueOf (currentposition.getMintensity())) ;

Create custom ArrayAdapter

Image
step - 1 create a listview in activity.xml.             create rootview as linerlayout step - 2 create a customview for listview.              here we are doing this because we have created a listview but what will be in that list view is                   decided by the custom view step - 3 create a custom class for custom layout. step - 4 create custom array adapter. public class NumbersViewAdapter extends ArrayAdapter<NumbersView> {          // invoke the suitable constructor of the ArrayAdapter class      public NumbersViewAdapter( @NonNull Context context, ArrayList<NumbersView> arrayList) {                      // pass the context and arrayList for the super          ...