Found 1966 Articles for Apps/Applications

What is Context on Android?

Azhar
Updated on 03-Jul-2020 06:09:18

6K+ Views

Definitionit's the context of current state of the application/object. It lets newly-created objects understand what has been going on. Typically, you call it to get information regarding another part of your program (activity and package/application). In the below program you will see that we have created a textView dynamically and passed context. This context is used to get the information about the environment.This example demonstrates how do I display context in an android textView.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 ... Read More

How can I disable/enable GPS programmatically in android?

Azhar
Updated on 03-Jul-2020 06:10:08

324 Views

This example demonstrates how do I disable/enable GPS programmatically 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 android.content.Context; import android.content.Intent; import android.location.LocationManager; import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    Button buttonGps;    Context context;    LocationManager locationManager ;    boolean GpsStatus ;    @Override    public void ... Read More

How to add a line break in an android textView?

Azhar
Updated on 03-Jul-2020 06:22:30

6K+ Views

This example demonstrates how do I add a line break in an android textView.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.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView);       textView.setTextColor(Color.RED);    } ... Read More

How to pass drawable between activities in android?

Azhar
Updated on 03-Jul-2020 06:23:20

700 Views

This example demonstrates how do I pass drawable between activities 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 android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity {    Button button;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       button = findViewById(R.id.button);       button.setOnClickListener(new View.OnClickListener() { ... Read More

How to change android overflow menu icon programmatically?

Azhar
Updated on 03-Jul-2020 06:24:42

2K+ Views

This example demonstrates how do I change android overflow menu icon 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.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Toolbar toolbar;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       toolbar ... Read More

How to convert ISO 8601 string to Date/time object in Android?

Azhar
Updated on 03-Jul-2020 05:53:39

1K+ Views

This example demonstrates how do I convert ISO 8601 string to date/time object 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 android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView); ... Read More

How to set OnclickListener on a radio button in android?

Azhar
Updated on 03-Jul-2020 05:56:54

2K+ Views

This example demonstrates how do I set OnclickListener on a radio button 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 android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } ... Read More

How can I use Marquee text in an android app?

Azhar
Updated on 03-Jul-2020 05:58:21

270 Views

This example demonstrates how do I use Marquee text 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity{    TextView textMarquee;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textMarquee = findViewById(R.id.textMarquee);       textMarquee.setText("Be the change that you ... Read More

How to get the difference between two dates in Android?

Azhar
Updated on 03-Jul-2020 05:59:08

3K+ Views

This example demonstrates how do I get the difference between two dates 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 android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; import java.text.SimpleDateFormat; import java.util.Date; public class MainActivity extends AppCompatActivity{    TextView textView;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView);     ... Read More

How to pass an arrayList to another activity using intents in Android?

Azhar
Updated on 03-Jul-2020 05:35:34

8K+ Views

This example demonstrates how do I pass an arrayList to another activity using intends 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 android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.util.ArrayList; public class MainActivity extends AppCompatActivity{    Button button;    ArrayList numbers = new ArrayList();    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       ... Read More

Advertisements