Java Code Examples for android.support.v4.app.FragmentActivity#getSystemService()

The following examples show how to use android.support.v4.app.FragmentActivity#getSystemService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsFragment.java    From Anti-recall with GNU Affero General Public License v3.0 6 votes vote down vote up
private void sendNotification() {
    FragmentActivity activity = getActivity();
    if (activity == null)
        return;
    NotificationManager manager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
    if (manager == null)
        return;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel("1", "1", NotificationManager.IMPORTANCE_DEFAULT);
        manager.createNotificationChannel(channel);
    }

    Notification notification = new NotificationCompat.Builder(activity, "1")
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("title")
            .setContentText("test")
            .setDefaults(Notification.FLAG_ONLY_ALERT_ONCE)
            .build();

    manager.notify(12, notification);
}
 
Example 2
Source File: CCPActivityBase.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 */
public void displaySoftKeyboard() {
    final FragmentActivity activity = mActionBarActivity;
    // Display the soft keyboard
    InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        View localView = activity.getCurrentFocus();
        if (localView != null && localView.getWindowToken() != null) {
            inputMethodManager.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}
 
Example 3
Source File: SettingsFragment.java    From Anti-recall with GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean isNotificationListenerWork() {
    Log.d(TAG, "isNotificationListenerWork: clickTime: " + (new Date().getTime() - App.timeCheckNotificationListenerServiceIsWorking));

    FragmentActivity activity = getActivity();
    if (activity == null)
        return false;
    NotificationManager manager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
    if (manager == null)
        return false;
    manager.cancel(12);

    return (new Date().getTime() - App.timeCheckNotificationListenerServiceIsWorking) < 5000;
}
 
Example 4
Source File: PortalAdapter.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
public PortalAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    new InitManager(context, new Runnable() {
        @Override
        public void run() {
            configLoaded = true;
            notifyDataSetChanged();
            loadForum();
            loadTopics();
        }
    }).init();
}
 
Example 5
Source File: PortalAdapter.java    From uservoice-android-sdk with MIT License 5 votes vote down vote up
public PortalAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    new InitManager(context, new Runnable() {
        @Override
        public void run() {
            configLoaded = true;
            notifyDataSetChanged();
            loadForum();
            loadTopics();
        }
    }).init();
}
 
Example 6
Source File: InstantAnswersAdapter.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
public InstantAnswersAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 
Example 7
Source File: MixedSearchAdapter.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
public MixedSearchAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 
Example 8
Source File: KnockSequenceListAdapter.java    From juicessh-portknocker with Apache License 2.0 4 votes vote down vote up
public KnockSequenceListAdapter(FragmentActivity activity, KnockSequence sequence) {
    this.activity = new WeakReference<FragmentActivity>(activity);
    this.sequence = sequence;
    this.inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 
Example 9
Source File: InstantAnswersAdapter.java    From uservoice-android-sdk with MIT License 4 votes vote down vote up
public InstantAnswersAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 
Example 10
Source File: MixedSearchAdapter.java    From uservoice-android-sdk with MIT License 4 votes vote down vote up
public MixedSearchAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}