/**
* To disable back button(when click back button nothing happen)
*/
@Override
public void onBackPressed() {
return;
}
Place for latest technology news, technology articles, technology reviews, Gadget News, and Gadget Update.
<activity android:name=".Application2/Activity2">
<intent-filter>
<action android:name="Application2.intent.action.Launch" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Now you can create an Intent to launch Activity2 from the Activity1 with this line of code:
Intent intent = new Intent("Application2.intent.action.Launch");
startActivity(intent);
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
requestLocationUpdates()
twice—once for NETWORK_PROVIDER
and once for GPS_PROVIDER
. But when you run the applicatin in emulator, you should use GPS provider to obtain your location.
GPS
|
Android's
Network Location Provider
|
Although
GPS is most accurate
|
Android's Network Location Provider
determines user location using cell tower and Wi-Fi signals
|
It only
works outdoors
|
Providing
location information in a way that works indoors and outdoors
|
It
quickly consumes battery power
|
Uses less battery power
|
It doesn’t
return the location as quickly as users want.
|
Responds faster
|
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainWindowActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg) {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("https://google.com"));
startActivity(viewIntent);
}
});
}
}