FileDocCategorySizeDatePackage
NetworkOverLimitActivity.javaAPI DocAndroid 5.1 API3738Thu Mar 12 22:22:42 GMT 2015com.android.systemui.net

NetworkOverLimitActivity

public class NetworkOverLimitActivity extends android.app.Activity
Notify user that a {@link NetworkTemplate} is over its {@link NetworkPolicy#limitBytes}, giving them the choice of acknowledging or "snoozing" the limit.

Fields Summary
private static final String
TAG
Constructors Summary
Methods Summary
private static intgetLimitedDialogTitleForTemplate(android.net.NetworkTemplate template)

        switch (template.getMatchRule()) {
            case MATCH_MOBILE_3G_LOWER:
                return R.string.data_usage_disabled_dialog_3g_title;
            case MATCH_MOBILE_4G:
                return R.string.data_usage_disabled_dialog_4g_title;
            case MATCH_MOBILE_ALL:
                return R.string.data_usage_disabled_dialog_mobile_title;
            default:
                return R.string.data_usage_disabled_dialog_title;
        }
    
public voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        final NetworkTemplate template = getIntent().getParcelableExtra(EXTRA_NETWORK_TEMPLATE);
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getLimitedDialogTitleForTemplate(template));
        builder.setMessage(R.string.data_usage_disabled_dialog);

        builder.setPositiveButton(android.R.string.ok, null);
        builder.setNegativeButton(
                R.string.data_usage_disabled_dialog_enable, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        snoozePolicy(template);
                    }
                });

        final Dialog dialog = builder.create();
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                finish();
            }
        });

        dialog.show();
    
private voidsnoozePolicy(android.net.NetworkTemplate template)

        final INetworkPolicyManager policyService = INetworkPolicyManager.Stub.asInterface(
                ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
        try {
            policyService.snoozeLimit(template);
        } catch (RemoteException e) {
            Log.w(TAG, "problem snoozing network policy", e);
        }