Example usage for android.content Intent ACTION_MANAGE_NETWORK_USAGE

List of usage examples for android.content Intent ACTION_MANAGE_NETWORK_USAGE

Introduction

In this page you can find the example usage for android.content Intent ACTION_MANAGE_NETWORK_USAGE.

Prototype

String ACTION_MANAGE_NETWORK_USAGE

To view the source code for android.content Intent ACTION_MANAGE_NETWORK_USAGE.

Click Source Link

Document

Activity Action: Show settings for managing network data usage of a specific application.

Usage

From source file:com.shalzz.attendance.activity.MainActivity.java

/**
 * Initialise a fragment/*  w  ww  . j a v  a2  s .c  o  m*/
 **/
public void init(Bundle bundle) {

    // Select either the default item (Fragments.ATTENDANCE) or the last selected item.
    mCurrentSelectedPosition = reloadCurrentFragment();

    // Recycle fragment
    if (bundle != null) {
        fragment = mFragmentManager.findFragmentByTag(FRAGMENT_TAG);
        mPreviousFragment = mFragmentManager.getFragment(bundle, PREVIOUS_FRAGMENT_TAG);
        Timber.d("current fag found: %s", fragment);
        Timber.d("previous fag found: %s", mPreviousFragment);
        selectItem(mCurrentSelectedPosition);
        showFragment(fragment);
    } else {

        if (getIntent().hasExtra(LAUNCH_FRAGMENT_EXTRA)) {
            mCurrentSelectedPosition = getIntent().getIntExtra(LAUNCH_FRAGMENT_EXTRA,
                    Fragments.ATTENDANCE.getValue());
        } else if (getIntent().getAction() != null
                && getIntent().getAction().equals(Intent.ACTION_MANAGE_NETWORK_USAGE)) {
            mCurrentSelectedPosition = Fragments.SETTINGS.getValue();
            Timber.i("MANAGE_NETWORK_USAGE intent received");
        }
        displayView(mCurrentSelectedPosition);
    }

    updateDrawerHeader();
}

From source file:cw.kop.autobackground.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i("MP", "onCreate");

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    AppSettings.initPrefs(prefs, getApplicationContext());

    switch (AppSettings.getTheme()) {
    default://from   w w w.j  av  a  2  s.  c  o  m
    case AppSettings.APP_LIGHT_THEME:
        setTheme(R.style.AppLightTheme);
        break;
    case AppSettings.APP_DARK_THEME:
        setTheme(R.style.AppDarkTheme);
        break;
    }

    super.onCreate(savedInstanceState);
    Configuration configuration = getResources().getConfiguration();

    if (configuration.screenWidthDp >= 600 || AppSettings.forceMultiPane()) {
        setContentView(R.layout.activity_layout_multi_pane);
    } else {
        setContentView(R.layout.activity_layout);
    }
    if (AppSettings.useFabric()) {
        final Fabric fabric = new Fabric.Builder(this).kits(new Crashlytics()).build();
        Fabric.with(fabric);
    }

    fragmentList = getResources().getStringArray(R.array.fragment_titles);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    navLayout = (LinearLayout) findViewById(R.id.navigation_drawer);
    navPicture = (ImageView) findViewById(R.id.nav_drawer_picture);

    navLayout.getLayoutParams().width = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            Math.min(320, configuration.screenWidthDp - 56), getResources().getDisplayMetrics()));

    CustomRelativeLayout navHeader = (CustomRelativeLayout) findViewById(R.id.nav_drawer_header);
    navHeader.getLayoutParams().height = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            Math.min(180, (configuration.screenWidthDp - 56) / 16f * 9), getResources().getDisplayMetrics()));
    navHeader.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(LiveWallpaperService.OPEN_IMAGE);
            sendBroadcast(intent);
        }
    });

    drawerList = (ListView) findViewById(R.id.nav_list);
    drawerList.setAdapter(new NavListAdapter(this, fragmentList));
    drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            getFragmentManager().popBackStack();
            selectItem(position, true);
        }
    });

    drawerList.setDividerHeight(0);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextAppearance(getApplicationContext(), R.style.ToolbarTitle);
    try {
        setSupportActionBar(toolbar);
    } catch (Throwable t) {

    }

    if (drawerLayout != null) {
        drawerList.setOnItemClickListener(new DrawerItemClickListener());
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open,
                R.string.drawer_close) {

            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                selectItem(newPosition, true);
                Intent closedIntent = new Intent(MainActivity.DRAWER_CLOSED);
                LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(closedIntent);
            }

            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                getFragmentManager().popBackStack();
                Intent openedIntent = new Intent(MainActivity.DRAWER_OPENED);
                LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(openedIntent);
            }

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                super.onDrawerSlide(drawerView, 0);
            }

        };

        drawerLayout.setDrawerListener(drawerToggle);
        drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
    } else {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    if (AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME)) {
        navLayout.setBackgroundColor(getResources().getColor(R.color.LIGHT_THEME_BACKGROUND));
        toolbar.setTitleTextColor(getResources().getColor(R.color.DARK_GRAY_OPAQUE));
    } else if (AppSettings.getTheme().equals(AppSettings.APP_DARK_THEME)) {
        navLayout.setBackgroundColor(getResources().getColor(R.color.DARK_THEME_BACKGROUND));
        toolbar.setTitleTextColor(getResources().getColor(R.color.LIGHT_GRAY_OPAQUE));
    } else if (AppSettings.getTheme().equals(AppSettings.APP_TRANSPARENT_THEME)) {
        navLayout.setBackgroundColor(getResources().getColor(R.color.TRANSPARENT_BACKGROUND));
        toolbar.setTitleTextColor(getResources().getColor(R.color.LIGHT_GRAY_OPAQUE));
    }

    if (sourceListFragment == null) {
        sourceListFragment = new SourceListFragment();
    }

    Bundle bundle = getIntent().getExtras();

    String action = getIntent().getAction();

    if (bundle != null && bundle.getInt("fragment", 0) > 0) {
        int position = bundle.getInt("fragment", 0);
        selectItem(position, false);
    } else if (savedInstanceState == null) {
        if (action != null && action.equals(Intent.ACTION_MANAGE_NETWORK_USAGE)) {
            selectItem(2, false);
        } else {
            selectItem(0, false);
        }
    }

    loadNavPicture();

    entryFilter = new IntentFilter();
    entryFilter.addAction(MainActivity.LOAD_NAV_PICTURE);

}

From source file:fr.kwiatkowski.apktrack.MainActivity.java

/**
 * This method received the intents passed to the activity and processes them.
 * @param i The intent to handle./*  w ww. ja  v  a  2s.  co m*/
 */
private void _handle_intent(Intent i) {
    // The user wants to filter the list.
    if (Intent.ACTION_SEARCH.equals(i.getAction())) {
        Log.v(TAG, "User search: " + i.getStringExtra(SearchManager.QUERY));
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
        boolean show_system = pref.getBoolean(SettingsFragment.KEY_PREF_SHOW_SYSTEM, false);

        String query = "%" + i.getStringExtra(SearchManager.QUERY) + "%";
        String where_clause = "(_displayname LIKE ? OR _packagename LIKE ?)";
        if (!show_system) {
            where_clause += " AND _systemapp = 0";
        }
        List<InstalledApp> results = InstalledApp.find(InstalledApp.class, where_clause, query, query);
        Log.v(TAG, results.size() + " application(s) match.");

        if (results.size() == 0) // No apps match the search.
        {
            Toast.makeText(getApplicationContext(), R.string.search_no_result, Toast.LENGTH_SHORT).show();
            return;
        }
        _app_display.filter_apps(results);
    } else if (Intent.ACTION_MANAGE_NETWORK_USAGE.equals(i.getAction())) {
        // Do not add to the backstack: back should return to the Intent sender.
        getSupportFragmentManager().beginTransaction().replace(R.id.container, new SettingsFragment()).commit();
    }
}