Posts

Showing posts from March, 2015

Getting The Current Location from the Android device Also getting the address from that location

hey guys in this tutorial i will show u guys how to get the location from your android device and find the address of the location from that device. please add these permissions public class LocationFinder implements LocationListener { Context context; Double lat, lon; Location location; public LocationFinder(Context c) { this.context = c; LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10, 1000 * 60 * 1, this); try { location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); setLat(location.getLatitude()); setLon(location.getLongitude()); }catch (Exception e){ Toast.makeText(c,"couldn't locate your location",Toast.LENGTH_LONG).show(); setLat(21.0000);

Adding Markers in Google Map and Focusing Camera when map loaded

Map fragment :xml design Map fragment class public class MapView extends Fragment { View view; Bundle bundle; GoogleMap map; Marker marker; String name, vicinity, lat, lng, distance; public SupportMapFragment mapFragment; ImageView home_button, map_button, review_button; public MapView() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (view == null) { view = inflater.inflate(R.layout.map_view, container, false); } else { ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } } return view; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState);

Creating a Broadcast Receiver in android

hey guys , In this tutorial  i am going to show how to create a simple broadcast receiver ,which makes your phone vibrate when the charger is connected 1 step: create an android project as you do always then create a class wich extends broadcast receiver class import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Vibrator; import android.widget.Toast; public class Vibrated extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent arg1) { Toast.makeText(context, "Don't panik but your time is up!!!!.", Toast.LENGTH_LONG).show(); // Vibrate the mobile phone Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);  vibrator.vibrate(4000); Toast.makeText(context, "vibrated!!!!.", Toast.LENGTH_LONG).show(); } } 2 step: in your androidmanifest.xml file add the vibrator pe

Handling multiple view Clicks

hey guys in this tutorial i will show you guys multiple ways to handle the clicks in the view of an android... 1 method:  ImageButton btplus = (ImageButton)findViewById(R.id.btplus); btplus.setOnClickListener( new ImageButton.OnClickListener(){ @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "+", Toast.LENGTH_SHORT).show(); } }); ImageButton btminus = (ImageButton)findViewById(R.id.btminus); btminus.setOnClickListener( new ImageButton.OnClickListener(){ @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "-", Toast.LENGTH_SHORT).show(); } }); 2 method: for implemnting this method your activity class must implement  OnClickListener interface  then override the onClick class ImageButton btminus = (ImageButton)findViewById(R.id.btminus); btminus.setOnClickListener(this); ImageButton