Get Fling Gesture Detection Working in an Android App

Azhar
Updated on 03-Jul-2020 08:40:51

812 Views

This example demonstrates how do I get fling gesture detection working in an android app.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.GestureDetector; import android.view.MotionEvent; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    GestureDetector gestureDetector;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       gestureDetector = new ... Read More

Send an Object from One Android Activity to Another Using Intents

Azhar
Updated on 03-Jul-2020 08:40:13

264 Views

This example demonstrates how do I send an object from one android activity to another using intents.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 – Create an object from a java class (Message.java)import java.io.Serializable; public class Message implements Serializable {    private static final long serialVersionUID = 1L;    private String message;    public String getMessage(){       return message;    }    public void setMessage(String ... Read More

Obtain Phone Number of Android Phone Programmatically

Azhar
Updated on 03-Jul-2020 08:39:23

1K+ Views

This example demonstrates how do I obtain the phone number of the android phone programmatically.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    TextView textView;    private static final int REQUEST_CODE = 101;    @Override    protected ... Read More

Get Spinner Value in Android

Azhar
Updated on 03-Jul-2020 08:37:09

5K+ Views

This example demonstrates how do I get spinner value in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 – Open res/values/strings.xml and add the following code    Sample           crane       Cuckoo       Pigeon       Pigeon       Eagle       Owl       Vulture       WoodPecker     ... Read More

Create Clickable Links in a TextView on Android

Azhar
Updated on 03-Jul-2020 08:32:53

3K+ Views

This example demonstrates how do I create clickable links in a textView on android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 – Open res/values/strings.xml and add the following code −    Sample    Tap here to open Link Step 4 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.method.LinkMovementMethod; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;   ... Read More

Throw Unchecked Exception from Checked Exception in Java

Maruthi Krishna
Updated on 03-Jul-2020 08:32:08

773 Views

When an exception is cached in a catch block, you can re-throw it using the throw keyword (which is used to throw the exception objects).While re-throwing exceptions you can throw the same exception as it is with out adjusting it as −try {    int result = (arr[a])/(arr[b]);    System.out.println("Result of "+arr[a]+"/"+arr[b]+": "+result); }catch(ArithmeticException e) {    throw e; }Or, wrap it within a new exception and throw it. When you wrap a cached exception within another exception and throw it, it is known as exception chaining or, exception wrapping, by doing this you can adjust your exception, throwing higher ... Read More

Dynamically Add Elements in ListView in Android

Azhar
Updated on 03-Jul-2020 08:31:00

3K+ Views

This example demonstrates how do I dynamically add elements in ListView in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                 Step 3 − Add the following code to src/MainActivity.javaimport java.util.ArrayList; import java.util.Arrays; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; public class MainActivity extends Activity {    ListView listview;    Button addButton; ... Read More

Add Footer in Android ListView

Azhar
Updated on 03-Jul-2020 08:30:11

982 Views

This example demonstrates how do I add footer in Android ListView.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 – Create a layout file.xml and name it as listView_footer.xml and add the following code −         Step 4 − Add the following code to src/MainActivity.javaimport java.util.ArrayList; import java.util.Arrays; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ArrayAdapter; import ... Read More

Send Emails Using Gmail from Android Application

Azhar
Updated on 03-Jul-2020 08:27:02

519 Views

This example demonstrates how do I send emails using gmail from my Android application.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                             Step 3 − Add the following code to src/MainActivity.javaimport android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity{    EditText editTextMail, editTextSubject, ... Read More

Create User Menu in PowerShell

Chirag Nagrekar
Updated on 03-Jul-2020 08:26:54

4K+ Views

When you are writing a script and if you want to provide the user to select one option among multiple values and based on it to execute the command, we can generally use the Switch command and for it, we will ask the user choice in the below script.There is another .Net method to create a user menu, we will see it after the example from the description mentioned above.a. Switch command methodFor the Switch command-based user selection, we will first display the message for the user and then give him a choice for the selection through Read-Host command as ... Read More

Advertisements