This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
if (Integer.parseInt(android.os.Build.VERSION.SDK) > 5 | |
&& keyCode == KeyEvent.KEYCODE_BACK | |
&& event.getRepeatCount() == 0) { | |
Log.d("CDA", "onKeyDown Called"); | |
onBackPressed(); | |
return true; | |
} | |
return super.onKeyDown(keyCode, event); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// member declarations | |
private float x1, x2; | |
private float p1, p2 = 0; | |
static final int MIN_DISTANCE = 150; | |
static final int MIN_MOVEMENT = 3; | |
View.setOnTouchListener(new View.OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Location getLastKnownLocation() { | |
// get location from any of the location providers that are available | |
locMan = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE); | |
List<String> providers = locMan.getProviders(true); | |
Location bestLocation = null; | |
// check for all providers | |
for (String provider : providers) { | |
Location l = locMan.getLastKnownLocation(provider); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isNetworkAvailable() { | |
ConnectivityManager connectivityManager | |
= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); | |
return activeNetworkInfo != null && activeNetworkInfo.isConnected(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long date = System.currentTimeMillis(); | |
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); // or MMM MM dd, yyyy h:mm a to get time also | |
String dateString = sdf.format(date); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
boolean isPopped=false; | |
double h; | |
double w; | |
LinearLayout popUpFrame; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RgbView extends View { | |
Paint p=new Paint(); | |
public RgbView(Context context) { | |
super(context); | |
init(null, 0); | |
} | |
public RgbView(Context context, AttributeSet attrs) { | |
super(context, attrs); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.testbed.projects.stackoverflow"> | |
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BackgroundService extends Service { | |
private static BroadcastReceiver mTickReceiver; | |
public BackgroundService() | |
{ | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.testing.name.locationservicetest; | |
import android.Manifest; | |
import android.content.Context; | |
import android.content.pm.PackageManager; | |
import android.location.Criteria; | |
import android.location.Location; | |
import android.location.LocationManager; | |
import android.os.AsyncTask; |