use of android.support.annotation.RequiresApi in project NewPipe by TeamNewPipe.
the class PermissionHelper method checkSystemAlertWindowPermission.
/**
* In order to be able to draw over other apps, the permission android.permission.SYSTEM_ALERT_WINDOW have to be granted.
* <p>
* On < API 23 (MarshMallow) the permission was granted when the user installed the application (via AndroidManifest),
* on > 23, however, it have to start a activity asking the user if he agree.
* <p>
* This method just return if canDraw over other apps, if it doesn't, try to get the permission,
* it does not get the result of the startActivityForResult, if the user accept, the next time that he tries to open
* it will return true.
*
* @param activity context to startActivityForResult
* @return returns {@link Settings#canDrawOverlays(Context)}
**/
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean checkSystemAlertWindowPermission(Activity activity) {
if (!Settings.canDrawOverlays(activity)) {
Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + activity.getPackageName()));
activity.startActivityForResult(i, PERMISSION_SYSTEM_ALERT_WINDOW);
return false;
} else
return true;
}
use of android.support.annotation.RequiresApi in project muzei by romannurik.
the class MuzeiWallpaperService method initialize.
private void initialize() {
FirebaseAnalytics.getInstance(this).setUserProperty("device_type", BuildConfig.DEVICE_TYPE);
SourceManager.subscribeToSelectedSource(MuzeiWallpaperService.this);
mNetworkChangeReceiver = new NetworkChangeReceiver();
IntentFilter networkChangeFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mNetworkChangeReceiver, networkChangeFilter);
// Ensure we retry loading the artwork if the network changed while the wallpaper was disabled
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
Intent retryIntent = TaskQueueService.maybeRetryDownloadDueToGainedConnectivity(this);
if (retryIntent != null && connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isConnected()) {
startService(retryIntent);
}
// Set up a thread to update notifications whenever the artwork changes
mNotificationHandlerThread = new HandlerThread("MuzeiWallpaperService-Notification");
mNotificationHandlerThread.start();
mNotificationContentObserver = new ContentObserver(new Handler(mNotificationHandlerThread.getLooper())) {
@Override
public void onChange(final boolean selfChange, final Uri uri) {
NewWallpaperNotificationReceiver.maybeShowNewArtworkNotification(MuzeiWallpaperService.this);
}
};
getContentResolver().registerContentObserver(MuzeiContract.Artwork.CONTENT_URI, true, mNotificationContentObserver);
// Set up a thread to update Android Wear whenever the artwork changes
mWearableHandlerThread = new HandlerThread("MuzeiWallpaperService-Wearable");
mWearableHandlerThread.start();
mWearableContentObserver = new ContentObserver(new Handler(mWearableHandlerThread.getLooper())) {
@Override
public void onChange(final boolean selfChange, final Uri uri) {
WearableController.updateArtwork(MuzeiWallpaperService.this);
}
};
getContentResolver().registerContentObserver(MuzeiContract.Artwork.CONTENT_URI, true, mWearableContentObserver);
// Set up a thread to update the Artwork Info shortcut whenever the artwork changes
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
mArtworkInfoShortcutHandlerThread = new HandlerThread("MuzeiWallpaperService-ArtworkInfoShortcut");
mArtworkInfoShortcutHandlerThread.start();
mArtworkInfoShortcutContentObserver = new ContentObserver(new Handler(mArtworkInfoShortcutHandlerThread.getLooper())) {
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
@Override
public void onChange(final boolean selfChange, final Uri uri) {
ArtworkInfoShortcutController.updateShortcut(MuzeiWallpaperService.this);
}
};
getContentResolver().registerContentObserver(MuzeiContract.Artwork.CONTENT_URI, true, mArtworkInfoShortcutContentObserver);
}
mInitialized = true;
}
use of android.support.annotation.RequiresApi in project Sudoku by mrbananasoup.
the class Game method openSettings.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void openSettings(View view) {
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivity(settingsIntent);
}
use of android.support.annotation.RequiresApi in project easy by MehdiBenmesa.
the class RendezVousActivity method buttonPressed.
@Override
public void buttonPressed(final JSONObject module) {
addDialog = getLayoutInflater().inflate(R.layout.rdv_dialog, null);
final TextView nom = (TextView) addDialog.findViewById(R.id.nomdialog);
final TextView date = (TextView) addDialog.findViewById(R.id.date);
final EditText heur = (EditText) addDialog.findViewById(R.id.heur);
final EditText value = (EditText) addDialog.findViewById(R.id.value);
dialog = new LovelyCustomDialog(this, R.style.EditTextTintTheme).setTopColorRes(R.color.darkRed).setView(addDialog).setTitle(R.string.text_input_title).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
dialog.show();
Button ok = (Button) addDialog.findViewById(R.id.ok);
Button annuler = (Button) addDialog.findViewById(R.id.cancel);
date.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDatePicker();
}
});
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
ajouterRdv(module.getString("_id"), date.getText().toString(), value.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
dialog.dismiss();
}
});
annuler.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
ondate = new DatePickerDialog.OnDateSetListener() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onDateSet(android.widget.DatePicker view, int year, int monthOfYear, int dayOfMonth) {
monthOfYear = monthOfYear + 1;
date.setText(year + "-" + monthOfYear + 1 + "-" + dayOfMonth);
calender.set(year, monthOfYear, dayOfMonth);
int dayOfWeek = 0;
dayOfWeek = calender.get(Calendar.DAY_OF_WEEK);
System.out.println("DAY_OF_WEEK : +======== " + dayOfWeek);
// studentsListAdapter.notifyDataSetChanged();
}
};
}
use of android.support.annotation.RequiresApi in project easy by MehdiBenmesa.
the class ModuleDetailFragment method onCreate.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReceiver = new DataReceiver(new Handler());
mReceiver.setReceiver(this);
exam = (TextView) getActivity().findViewById(R.id.exam);
controle = (TextView) getActivity().findViewById(R.id.control);
intero = (TextView) getActivity().findViewById(R.id.intero);
tp = (TextView) getActivity().findViewById(R.id.tps);
SessionManager sessionManager = new SessionManager(getContext());
userID = sessionManager.getIdUser();
// String Module = sessionManager
NoteService.getNoteByStudent(getContext(), mReceiver);
if (getArguments().containsKey(ARG_ITEM_ID)) {
// load dummy item by using the passed item ID.
// accident = AppContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
}
// Toast.makeText(getContext() , moduleID , Toast.LENGTH_LONG).show();
setHasOptionsMenu(true);
}
Aggregations