Search in sources :

Example 1 with RequiresApi

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;
}
Also used : Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi)

Example 2 with RequiresApi

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;
}
Also used : IntentFilter(android.content.IntentFilter) HandlerThread(android.os.HandlerThread) ConnectivityManager(android.net.ConnectivityManager) RequiresApi(android.support.annotation.RequiresApi) Handler(android.os.Handler) Intent(android.content.Intent) Uri(android.net.Uri) ContentObserver(android.database.ContentObserver)

Example 3 with RequiresApi

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);
}
Also used : Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi)

Example 4 with RequiresApi

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();
        }
    };
}
Also used : EditText(android.widget.EditText) DatePickerDialog(android.app.DatePickerDialog) JSONException(org.json.JSONException) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Button(android.widget.Button) LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog) RequiresApi(android.support.annotation.RequiresApi) TextView(android.widget.TextView)

Example 5 with RequiresApi

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);
}
Also used : SessionManager(dz.easy.androidclient.Util.SessionManager) Handler(android.os.Handler) DataReceiver(dz.easy.androidclient.Services.DataReceiver) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)191 Intent (android.content.Intent)30 NotificationChannel (android.app.NotificationChannel)29 View (android.view.View)24 NotificationManager (android.app.NotificationManager)17 Allocation (android.renderscript.Allocation)14 ViewGroup (android.view.ViewGroup)14 Bitmap (android.graphics.Bitmap)13 RecyclerView (android.support.v7.widget.RecyclerView)13 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 TextView (android.widget.TextView)12 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 Handler (android.os.Handler)10 Cipher (javax.crypto.Cipher)10 StatFs (android.os.StatFs)9 Button (android.widget.Button)8 IOException (java.io.IOException)8 SuppressLint (android.annotation.SuppressLint)7