This file contains 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 class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
int year = calendar.get(Calendar.YEAR); | |
int month = calendar.get(Calendar.MONTH); | |
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); | |
return new DatePickerDialog(getActivity(), this, year, month, dayOfMonth); | |
} |
This file contains 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 class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); | |
int minute = calendar.get(Calendar.MINUTE); | |
return new TimePickerDialog(getActivity(), this, hourOfDay, minute, true); | |
} |
This file contains 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 String getSensorInfo(SensorManager sensorManager) { | |
Iterator iterator = sensorManager.getSensorList(Sensor.TYPE_ALL).iterator(); | |
Sensor sensor; | |
String s = ""; | |
while (iterator.hasNext()) { | |
sensor = (Sensor)iterator.next(); | |
s = s + sensor.getName() + " MADE BY " + sensor.getVendor() + "\n"; | |
} | |
return s; | |
} |
This file contains 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
import android.app.Activity; | |
import android.hardware.Sensor; | |
import android.hardware.SensorEvent; | |
import android.hardware.SensorEventListener; | |
import android.hardware.SensorManager; | |
import android.os.Bundle; | |
import android.widget.TextView; | |
public class MainActivity extends Activity implements SensorEventListener { |
This file contains 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 Activity { | |
private ScreenStateReceiver mReceiver; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); | |
intentFilter.addAction(Intent.ACTION_SCREEN_OFF); |
This file contains 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 isMyServiceRunning() { | |
ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE); | |
for (ActivityManager.RunningServiceInfo serviceInfo: activityManager.getRunningServices(Integer.MAX_VALUE)) { | |
if (ShakeLockService.class.getName().equals(serviceInfo.service.getClassName())) { | |
return true; | |
} | |
} | |
return false; | |
} |
This file contains 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
import android.app.Activity; | |
import android.content.Context; | |
import android.preference.Preference; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.LinearLayout; | |
import com.google.ads.AdRequest; | |
import com.google.ads.AdSize; |
This file contains 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
import android.app.Activity; | |
import android.content.Context; | |
import android.preference.Preference; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.LinearLayout; | |
import com.amazon.device.ads.AdLayout; | |
import com.amazon.device.ads.AdRegistration; |
This file contains 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
<receiver android:name=".MyAppWidgetProvider"> | |
<intent-filter> | |
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> | |
</intent-filter> | |
<meta-data | |
android:name="android.appwidget.provider" | |
android:resource="@xml/appwidget_info" /> | |
</receiver> |
This file contains 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
import android.os.Bundle; | |
import android.support.v4.app.FragmentActivity; | |
import android.widget.Toast; | |
public class MainActivity extends FragmentActivity implements SampleFragment.OnArticleSelectedListener { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); |
OlderNewer