Example usage for android.os StrictMode enableDefaults

List of usage examples for android.os StrictMode enableDefaults

Introduction

In this page you can find the example usage for android.os StrictMode enableDefaults.

Prototype

public static void enableDefaults() 

Source Link

Document

Enable the recommended StrictMode defaults, with violations just being logged.

Usage

From source file:ca.farrelltonsolar.classic.MonitorApplication.java

public void onCreate() {
    super.onCreate();

    MonitorApplication.context = getApplicationContext();
    if (Constants.DEVELOPER_MODE) {
        StrictMode.enableDefaults();
    }//from w w w. ja  v  a  2s .  c o  m
    InitializeChargeStateLookup();
    InitializeChargeStateTitleLookup();
    InitializeMessageLookup();
    try {
        configuration = ComplexPreferences.getComplexPreferences(this, null, Context.MODE_PRIVATE);
        chargeControllers = configuration.getObject("devices", ChargeControllers.class);
    } catch (Exception ex) {
        Log.w(getClass().getName(), "getComplexPreferences failed to load");
        chargeControllers = null;
    }
    if (chargeControllers == null) { // save empty collection
        chargeControllers = new ChargeControllers(context);
    }
    if (chargeControllers.uploadToPVOutput()) {
        startService(new Intent(this, PVOutputService.class)); // start PVOutputService intent service
    }
    this.registerActivityLifecycleCallbacks(this);
    bindService(new Intent(this, UDPListener.class), UDPListenerServiceConnection, Context.BIND_AUTO_CREATE);
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    if (wifi != null) {
        wifiLock = wifi.createWifiLock("ClassicMonitor");
    }
    Log.d(getClass().getName(), "onCreate complete");
}

From source file:com.example.joeroger.homework2.activity.WeatherActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Turn on strict mode in debug builds
    if (BuildConfig.DEBUG) {
        StrictMode.enableDefaults();
    }//from   www . j  a v a  2s.com

    setContentView(R.layout.activity_weather);

    setSupportActionBar((Toolbar) findViewById(R.id.toolBar));
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
        Spinner spinner = (Spinner) findViewById(R.id.city_spinner);
        citySpinnerCursorAdapter = new CitySpinnerCursorAdapter(actionBar.getThemedContext(), null);
        spinner.setAdapter(citySpinnerCursorAdapter);
        spinner.setOnItemSelectedListener(this);
        ViewCompat.setElevation(spinner, 0);
    }

    HandlerThread handlerThread = new HandlerThread("WeatherActivityThread");
    handlerThread.start();
    handler = new Handler(handlerThread.getLooper(), this);

    resolvingError = savedInstanceState != null && savedInstanceState.getBoolean(STATE_RESOLVING_ERROR);

    CityConditionsLoaderCallbacks.initLoader(getSupportLoaderManager(), this, this,
            CitySpinnerCursorAdapter.PROJECTION, CityConditionsContract.WHERE_CURRENT_OR_FAVORITE,
            CityConditionsContract.WHERE_CURRENT_OR_FAVORITE_ARGS);
}

From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        StrictMode.enableDefaults();
    }//w  w  w .j  av  a 2 s.  co  m
    super.onCreate(savedInstanceState);
    setContentView();
    setupPrereqs();
    if (!skipSetup(savedInstanceState)) {
        setupCommonFragments(savedInstanceState);
        setupCommonViews();
        doSetup(savedInstanceState);
    }
}

From source file:net.eledge.android.europeana.gui.activity.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    inject(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(toolbar);/*  w  ww . ja v a  2s.  c  om*/

    searchController.registerListener(SearchActivity.class, this);
    searchController.searchPageSize = getResources().getInteger(R.integer.search_result_pagesize);

    mFacetsAdaptor = new FacetAdapter((EuropeanaApplication) getApplication(), this);

    mFacetsList.setAdapter(mFacetsAdaptor);

    // enable ActionBar app icon to behave as action to toggle nav drawer
    //        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //        getSupportActionBar().setHomeButtonEnabled(true);

    if (mDrawerLayout != null) {
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_facets_open,
                R.string.drawer_facets_close) {
            public void onDrawerClosed(View view) {
                // getActionBar().setTitle(mTitle);
                supportInvalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
                // getActionBar().setTitle(mDrawerTitle);
                supportInvalidateOptionsMenu();
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        mDrawerToggle.setDrawerIndicatorEnabled(false);
    }

    if (Config.DEBUGMODE) {
        StrictMode.enableDefaults();
    }
    createResultFragment();
    if (savedInstanceState != null && searchController.hasResults()) {
        updateFacetDrawer();
        return;
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        createNdefPushMessageCallback();
    }
    handleIntent(getIntent());
}

From source file:com.example.android.navigationdrawerexample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.enableDefaults(); //STRICT MODE ENABLED

    db = new DBHelper(this);
    session = new Session(getApplicationContext());

    inflatedView = getLayoutInflater().inflate(R.layout.full_layout, null);
    mTitle = mDrawerTitle = getTitle();/*from  w  w  w.  ja v a 2 s .  co m*/
    login_layout = (RelativeLayout) findViewById(R.id.login_layout);
    //   order_list_layout= (RelativeLayout) findViewById(R.id.order_list_layout);
    signup_layout = (RelativeLayout) findViewById(R.id.signup_layout);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    actionBar = getActionBar();

    text = (TextView) inflatedView.findViewById(R.id.user_name);
    login_option = (TextView) inflatedView.findViewById(R.id.textView1);

    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    order_list = (ListView) findViewById(R.id.order_list);

    final LayoutInflater factory = getLayoutInflater();

    final View vendor_menu = factory.inflate(R.layout.vendor_menu, null);
    final View order_menu = factory.inflate(R.layout.my_order, null);
    menu_list = (ListView) vendor_menu.findViewById(R.id.menu_list);
    // loginPopup= (TextView) vendor_menu.findViewById(R.id.menu_title);
    // Log.d
    //menu_list.addView(order_menu,0);

    Signup = (Button) findViewById(R.id.Signup);
    Gosignup = (Button) findViewById(R.id.Gosignup);
    Login = (ImageButton) findViewById(R.id.Login);

    Sign_username = (EditText) findViewById(R.id.SignUsername);
    Sign_name = (EditText) findViewById(R.id.vendor);
    Sign_pass = (EditText) findViewById(R.id.SignPass);
    Sign_cpass = (EditText) findViewById(R.id.SignCpass);
    Sign_phone = (EditText) findViewById(R.id.Phone);

    Login_pass = (EditText) findViewById(R.id.Logpass);
    Login_email = (EditText) findViewById(R.id.Logusername);

    // Log_username= (EditText) findViewById(R.id.Logusername);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    adapter = new MyAdapter(this);
    //adapter2=new MyAdapter2(this);
    // menu_adapter=new MyAdapter2(this);
    mDrawerList.setAdapter(adapter);
    mDrawerList.setDividerHeight(0);
    //mDrawerList.setAdapter(adapter);
    // order_list.setAdapter(adapter2);
    // menu_list.setAdapter(menu_adapter);

    menu_list.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, adapter.mPlanetTitles));

    ImageView floatoption = new ImageView(this);
    floatoption.setImageResource(R.drawable.foption);

    ImageView floatadd = new ImageView(this);
    floatadd.setImageResource(R.drawable.fplus);

    floatin = new ImageView(this);
    floatin.setImageResource(R.drawable.flogin);

    floatout = new ImageView(this);
    floatout.setImageResource(R.drawable.flogout);

    ImageView floatrefresh = new ImageView(this);
    floatrefresh.setImageResource(R.drawable.refresh);

    itemBuilder = new SubActionButton.Builder(this);

    loginout = itemBuilder.setContentView(floatin).build();
    refresh = itemBuilder.setContentView(floatrefresh).build();
    additem = itemBuilder.setContentView(floatadd).build();

    actionButton = new FloatingActionButton.Builder(this).setContentView(floatoption).build();

    actionMenu = new FloatingActionMenu.Builder(this).addSubActionView(loginout).addSubActionView(additem)
            .addSubActionView(refresh)

            // ...
            .attachTo(actionButton).build();

    Signup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            View v = mDrawerList.getChildAt(0);
            View v2 = mDrawerList.getChildAt(5);

            text = (TextView) v.findViewById(R.id.user_name);
            login_option = (TextView) v2.findViewById(R.id.textView1);
            profile = (ImageView) v.findViewById(R.id.user_image);
            profile.setImageResource(R.drawable.welcome);
            text.setTextSize(20);
            text.setTextColor(Color.MAGENTA);
            text.setText("" + Sign_name.getText().toString());

            login_option.setText("Logout");

            floatout.setImageResource(R.drawable.flogout);
            // loginout.setContentView(floatout);
            long id = db.Insert(Sign_username.getText().toString(), Sign_name.getText().toString(),
                    Sign_pass.getText().toString(), Sign_phone.getText().toString());

            Log.d("This is-----------==", (String) text.getText() + id);

            //mDrawerList.invalidateViews();

            //mDrawerList.removeViewAt(0);
            adapter.notifyDataSetChanged();

            loginout.removeView(floatin);
            loginout.setContentView(floatout);

            order_list.setVisibility(View.VISIBLE);
            signup_layout.setVisibility(View.INVISIBLE);
            login_layout.setVisibility(View.INVISIBLE);

        }
    });

    Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            user_name = Login_email.getText().toString();
            user_pass = Login_pass.getText().toString();

            new GetAllCustomerTask().execute(new ApiConnector());
            new Order_details().execute(new ApiConnector());

        }
    });

    if (!session.getusename().equals("")) {
        user_id = session.getusename();
        user_name = session.getusename();
        user_pass = session.getpassword();
        login_layout.setVisibility(View.INVISIBLE);
        new GetAllCustomerTask().execute(new ApiConnector());
        // new Order_details().execute(new ApiConnector());
        // View vt = mDrawerList.getChildAt(0);
        //login_check(jsonArray);

        //new Order_details().execute(new ApiConnector());
    }

    additem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logged_in) {
                Intent i = new Intent(getApplicationContext(), Add_Item.class);
                startActivity(i);
            } else
                Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show();

        }
    });
    loginout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logged_in) {
                session.setusename("", "");
                finish();
                startActivity(getIntent());
                Toast.makeText(getApplicationContext(), "You are Loged Out", Toast.LENGTH_SHORT).show();
            } else
                Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show();

        }
    });

    Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            user_name = Login_email.getText().toString();
            user_pass = Login_pass.getText().toString();
            new GetAllCustomerTask().execute(new ApiConnector());
            //   new Order_details().execute(new ApiConnector());

        }
    });

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    order_list.setOnItemClickListener(new OrderItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF3BBD8F));

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            text = (TextView) inflatedView.findViewById(R.id.user_name);
            Log.d("Thit is----------------", (String) text.getText());
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }

}