Example usage for android.os StrictMode setThreadPolicy

List of usage examples for android.os StrictMode setThreadPolicy

Introduction

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

Prototype

public static void setThreadPolicy(final ThreadPolicy policy) 

Source Link

Document

Sets the policy for what actions on the current thread should be detected, as well as the penalty if such actions occur.

Usage

From source file:com.example.savedollars.ProductTotalPriceDisplay.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
            .detectNetwork().penaltyLog().build());

    System.out.println("Inside Product price display class");
    String barcodeNumber = (getIntent().getStringExtra("barcodeNumber"));

    /* If barcode number is scanned from main screen, Google API server
     * call is made to retrieve the product information. If we are 
     * returning from existing view ( shipping, stocks) no server call
     * is made. We display the product information already stored in 
     * JSONData//from w  w w .j  ava 2  s  .com
     */
    System.out.println("Barcode number is " + barcodeNumber);
    if (barcodeNumber != null) {
        getProductDetails(barcodeNumber);
    } else {
        JSONData = (getIntent().getStringExtra("JsonData"));
        System.out.println("Inside product price , JSON Data is " + JSONData);
        parseJsonData(JSONData);
    }

    super.onCreate(savedInstanceState);
    System.out.println("Invoking pdttotalpriceview");
    setContentView(R.layout.pdttotalpriceview);

    //Setting Product Name
    TextView productName = (TextView) findViewById(R.id.pdtNameTextView);
    productName.setText(pdtName);

    Iterator objMapIterator = sortedMap.entrySet().iterator();

    int i = 0;
    System.out.println("3 Updating INFO totalCount:" + totalCount);

    PDT_INFO = new String[totalCount][2];
    while (objMapIterator.hasNext()) {
        Map.Entry keyValuePairs = (Map.Entry) objMapIterator.next();
        System.out.println("i = " + i);
        System.out.println("Save DDollars Merchant Name" + String.valueOf(keyValuePairs.getKey()));
        System.out.println("Save DDollars Merchant Price :" + String.valueOf(keyValuePairs.getValue()));
        PDT_INFO[i][0] = String.valueOf(keyValuePairs.getKey());
        PDT_INFO[i][1] = "$" + String.valueOf(keyValuePairs.getValue());
        System.out.println(
                "While Array Merchant Name:" + PDT_INFO[i][0] + "Array Merchant Price:" + PDT_INFO[i][1]);
        i++;
    }
    System.out.println("Total Updated Rows: " + i + " < totalCount:" + totalCount);

    ListViewAdapter listv = new ListViewAdapter(this, PDT_INFO);

    setListAdapter(listv);
    System.out.println("INFO Updated leter");

}

From source file:com.example.chilipepper.finalgooglemapsproject.MainActivity.java

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

    lv = (ListView) findViewById(R.id.list);

    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);

    tabHost.setup();/*  w ww. j ava  2  s . c o  m*/

    TabHost.TabSpec tabSpec = tabHost.newTabSpec("list");
    tabSpec.setContent(R.id.tabList);
    tabSpec.setIndicator("List");
    tabHost.addTab(tabSpec);

    tabSpec = tabHost.newTabSpec("Map");
    tabSpec.setContent(R.id.tabMap);
    tabSpec.setIndicator("Map");
    tabHost.addTab(tabSpec);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

    StrictMode.setThreadPolicy(policy);

    MapFragment mapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
    mapFragment.getMapAsync(this);

}

From source file:cc.softwarefactory.lokki.android.MainApplication.java

@Override
public void onCreate() {

    Log.e(TAG, "Lokki started component");

    loadSetting();//from   www  .  j ava 2s .  co  m

    locationDisabledPromptShown = false;

    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); // Use 1/8th of the available memory for this memory cache.
    final int cacheSize = maxMemory / 8;
    avatarCache = new LruCache<String, Bitmap>(cacheSize) {
        @Override
        protected int sizeOf(String key, Bitmap bitmap) {
            // The cache size will be measured in kilobytes rather than number of items.
            return (bitmap.getRowBytes() * bitmap.getHeight()) / 1024;
        }
    };

    String iDontWantToSeeString = PreferenceUtils.getString(this, PreferenceUtils.KEY_I_DONT_WANT_TO_SEE);
    if (!iDontWantToSeeString.isEmpty()) {
        try {
            MainApplication.iDontWantToSee = new JSONObject(iDontWantToSeeString);
        } catch (JSONException e) {
            MainApplication.iDontWantToSee = null;
            Log.e(TAG, e.getMessage());
        }
    } else {
        MainApplication.iDontWantToSee = new JSONObject();
    }
    Log.e(TAG, "MainApplication.iDontWantToSee: " + MainApplication.iDontWantToSee);

    if (DEVELOPER_MODE) {

        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());

        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects()
                //.detectLeakedClosableObjects()
                .penaltyLog().penaltyDeath().build());
    }

    super.onCreate();
}

From source file:org.spinsuite.login.T_Connection.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setContentView(R.layout.t_connection);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    et_UrlSoap = (EditText) findViewById(R.id.et_UrlSoap);
    et_Method = (EditText) findViewById(R.id.et_Method);
    et_Timeout = (EditText) findViewById(R.id.et_Timeout);
    et_NameSpace = (EditText) findViewById(R.id.et_NameSpace);
    ch_SaveSD = (CheckBox) findViewById(R.id.ch_SaveSD);

    // Carlos Parada Setting Parameters for SFAndroid Service Call 
    et_UrlSoap.setText("http://193.1.1.243:8080/ADInterface/services/SFAndroidService");
    et_NameSpace.setText("http://www.erpcya.com/");
    et_Method.setText("InitialLoad");
    //End Carlos Parada

    butt_InitSync = (Button) findViewById(R.id.butt_InitSync);

    //lockFront();

    //   Init Sync
    butt_InitSync.setOnClickListener(new OnClickListener() {

        @Override/*from w w  w.  ja  v  a 2  s .c  o  m*/
        public void onClick(View v) {
            if (valid()) {
                synchronize();
                lockFront();
            }
        }
    });
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.HomeActivity.java

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

    if (isFinishing()) {
        return;//from w  w w  . j  av  a  2  s  .  c o  m
    }
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
    UIUtils.enableDisableActivitiesByFormFactor(this);
    setContentView(R.layout.activity_home);
    FragmentManager fm = getSupportFragmentManager();
    setTitle(R.string.app_name);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    String homeScreenLabel;
    if (mViewPager != null) {
        // Phone setup
        mViewPager.setAdapter(new HomePagerAdapter(getSupportFragmentManager()));
        mViewPager.setOnPageChangeListener(this);
        mViewPager.setPageMarginDrawable(R.drawable.grey_border_inset_lr);
        mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width));

        final ActionBar actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.addTab(actionBar.newTab().setText(R.string.title_my_schedule).setTabListener(this));
        actionBar.addTab(actionBar.newTab().setText(R.string.title_explore).setTabListener(this));
        actionBar.addTab(actionBar.newTab().setText(R.string.title_stream).setTabListener(this));
        setHasTabs();

        if (getIntent() != null && TAB_EXPLORE.equals(getIntent().getStringExtra(EXTRA_DEFAULT_TAB))
                && savedInstanceState == null) {
            mViewPager.setCurrentItem(1);
        }

        homeScreenLabel = getString(R.string.title_my_schedule);

    } else {
        mSocialStreamFragment = (SocialStreamFragment) fm.findFragmentById(R.id.fragment_stream);

        homeScreenLabel = "Home";
    }
    getSupportActionBar().setHomeButtonEnabled(false);
    triggerRefresh();

    EasyTracker.getTracker().sendView(homeScreenLabel);
    LOGD("Tracker", homeScreenLabel);

}

From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java

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

    setContentView(R.layout.activity_main);
    icon = (ImageView) findViewById(android.R.id.icon);
    sideNavigationView = (SideNavigationView) findViewById(R.id.side_navigation_view);
    sideNavigationView.setMenuItems(R.menu.side_navigation_menu);
    sideNavigationView.setMenuClickCallback(this);

    if (getIntent().hasExtra(EXTRA_TITLE)) {
        String title = getIntent().getStringExtra(EXTRA_TITLE);
        int resId = getIntent().getIntExtra(EXTRA_RESOURCE_ID, 0);
        setTitle(title);// ww w  .j a va 2  s  . c o m
        icon.setImageResource(resId);
        sideNavigationView.setMode(getIntent().getIntExtra(EXTRA_MODE, 0) == 0 ? Mode.LEFT : Mode.RIGHT);
    }

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
            .detectNetwork().penaltyLog().build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
    {
        String title = "http://meiriyiwen.com/index/mobile";
        //setTitle(title);
        WebView uiwebview = (WebView) findViewById(R.id.meiriyiwenWeb);
        uiwebview.setBackgroundColor(Color.BLACK);
        uiwebview.setWebViewClient(new Callback());
        uiwebview.getSettings().setBuiltInZoomControls(true);
        uiwebview.getSettings().setJavaScriptEnabled(true);
        uiwebview.loadUrl(title);

    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}

From source file:com.github.notizklotz.derbunddownloader.issuesgrid.DownloadedIssuesActivity.java

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

    if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
    }/* w w  w  . ja  v  a2 s  . com*/

    PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preferences, false);

    if (!PreferenceManager.getDefaultSharedPreferences(this).contains(KEY_ALARM_MIGRATED)) {
        Log.i(getClass().getSimpleName(), "Migrating alarms");
        AutomaticIssueDownloadAlarmManager_.getInstance_(this).updateAlarm();
        PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(KEY_ALARM_MIGRATED, true).apply();
    }
}

From source file:com.brodev.socialapp.view.MarketPlaceDetail.java

/** Called when the activity is first created. */
@Override//w w w .jav a  2 s . co  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.market_place_content_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Bundle bundle = getIntent().getExtras();
    marketPlace = (MarketPlace) bundle.get("marketplace");

    phraseManager = new PhraseManager(getApplicationContext());
    user = (User) getApplicationContext();
    colorView = new ColorView(getApplicationContext());
    this.imageGetter = new ImageGetter(getApplicationContext());

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    if (marketPlace.getTime_stamp().equals("0")) {
        this.getMarketPlaceAdapter();
    }

    getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "marketplace.marketplace"));
    initView();

    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "marketplace");
    comment.putInt("itemId", marketPlace.getListing_id());
    comment.putInt("totalComment", marketPlace.getTotal_comment());
    comment.putInt("total_like", marketPlace.getTotal_like());
    comment.putBoolean("no_share", false);
    comment.putBoolean("is_liked", marketPlace.getIs_liked());
    comment.putBoolean("can_post_comment", marketPlace.getCan_post_comment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();
}

From source file:org.lytsing.android.weibo.ui.ComposeActivity.java

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

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

    StrictMode.setThreadPolicy(policy);

    imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

    initView();//from   w  w w  .  ja v  a  2  s  .  c o  m

    initGridView();

    //location_ajax();
}

From source file:com.brodev.socialapp.view.MusicPlaySong.java

/** Called when the activity is first created. */
@Override//from  www .j a va2 s  . c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.music_player);

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    user = (User) getApplication().getApplicationContext();
    colorView = new ColorView(getApplicationContext());

    Bundle bundle = getIntent().getExtras();

    music = (Music) bundle.get("song");

    if (music.getTitle().equals("")) {
        this.getMusicAdapter();
    }
    initView();
    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "music_song");
    comment.putInt("itemId", Integer.parseInt(music.getSong_id()));
    comment.putInt("totalComment", Integer.parseInt(music.getTotal_comment()));
    comment.putInt("total_like", Integer.parseInt(music.getTotal_like()));
    comment.putBoolean("no_share", music.isShare());
    comment.putBoolean("is_liked", music.isLiked());
    comment.putBoolean("can_post_comment", music.isCanPostComment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();

}