List of usage examples for android.os StrictMode setThreadPolicy
public static void setThreadPolicy(final ThreadPolicy policy)
From source file:com.vuze.android.remote.rpc.RPC.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private static void revertNasty(ThreadPolicy oldPolicy) { if (oldPolicy == null) { return;/* www. ja va 2 s. com*/ } StrictMode.setThreadPolicy(oldPolicy); }
From source file:com.amgems.uwschedule.ui.HomeActivity.java
/** * Helper method for enabling death penalty on strict mode. *//*from ww w .ja v a 2 s .c o m*/ private static void enableDeathThreadPolicy() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().build()); }
From source file:ca.ualberta.cmput301f13t13.storyhoard.serverClasses.ServerManager.java
/** * Calls searchById() in the ESRetrieval class to retrieve a story on the * server by id. If no response matching the given id is found, the value * returned is null. Note also that in this application, the id's will be * strings in the format of a UUID. The ids will also be corresponding to * story ids, and the responses' content are story objects in JSON string * format. </br></br>//from w w w. j a va2 s . co m * * An example call: * </br></br> * String server = "http://cmput301.softwareprocess.es:8080/cmput301f13t13/stories/" </br> * UUID id = 5231b533-ba17-4787-98a3-f2df37de2aD7; </br> * Story myStory = getById(id); </br></br> * * myStory will contain the story that was searched for, or null if it * didn't exist on the server. </br></br> * * One more thing to note is that this operation is currently done on the * main UI thread of the android application, which is why the * ThreadPolicy code is needed. * * @param id * Will be a 128-bit UUID value. See the above example to see the * format of a UUID object. */ public Story getById(UUID id) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); // search by id return esRetrieval.searchById(id.toString(), server); }
From source file:com.example.android.navigationdrawerexample.Controller.PilihanController.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); session = new SessionManager(getApplicationContext()); this.detailMahasiswa = session.getUserDetails(); this.username = detailMahasiswa.get("username"); this.detailMahasiswa.put("role", "2"); this.role = Integer.parseInt(detailMahasiswa.get("role")); mTitle = mDrawerTitle = getTitle();// w w w . j ava 2 s.c o m mPlanetTitles = getResources().getStringArray(R.array.planets_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); fetch = (Button) findViewById(R.id.fetch); text = (TextView) findViewById(R.id.text); et = (EditText) findViewById(R.id.et); dataList = new ArrayList<DrawerItem>(); dataList.add(new DrawerItem("Jadwal Asistensi", R.drawable.ic_jadwal)); dataList.add(new DrawerItem("Profil", R.drawable.ic_person_grey)); dataList.add(new DrawerItem("Kelas", R.drawable.ic_kelas)); dataList.add(new DrawerItem("Forum", R.drawable.ic_forum)); dataList.add(new DrawerItem("Admin", R.drawable.ic_admin)); dataList.add(new DrawerItem("Logout", R.drawable.ic_logout)); adapter = new CustomDrawerAdapter(this, R.layout.custom_drawer_item, dataList); // 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 /*mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mPlanetTitles));*/ mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // 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() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } }
From source file:com.example.georg.theupub.AdministratorActivity.java
public boolean addPointss(int numpoints) { int currentpoints = 0; Connection conn = null;//www.j av a2 s . c o m StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); String dbURL = "jdbc:jtds:sqlserver://apollo.in.cs.ucy.ac.cy:1433"; try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); } catch (ClassNotFoundException e) { return false; } Properties properties = new Properties(); properties.put("user", "upub"); properties.put("password", "XuZ3drup"); properties.put("databaseName", "upub"); try { conn = DriverManager.getConnection(dbURL, properties); } catch (SQLException e) { return false; } String SQL = "Select * From [dbo].[User] where ID='" + re + "'"; Statement stmt = null; try { stmt = conn.createStatement(); } catch (SQLException e) { return false; } ResultSet rs = null; try { rs = stmt.executeQuery(SQL); } catch (SQLException e) { return false; } try { if (rs.next()) { System.out.print(rs.getInt(7)); currentpoints = rs.getInt(7); } } catch (SQLException e) { return false; } String pro = "EXEC dbo.addpoints ?,?"; PreparedStatement ps = null; try { ps = conn.prepareStatement(pro); ps.setEscapeProcessing(true); ps.setInt(1, Integer.parseInt(re)); ps.setInt(2, currentpoints + numpoints); ps.execute(); } catch (SQLException e) { return false; } return true; }
From source file:com.sandklef.coachapp.activities.TopActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // TEMP Settings TODO: Make this flexible, // Should be received via the bundle instead // // Club c11 = new Club("e0b7098f-b7e1-4fe4-89bb-22c4d83f1141", "IK Nord"); // currentClub = new Club("c04b2bdd-9fef-4123-b4cb-e122081e1868", "AHK"); currentClub = new Club("e0b7098f-b7e1-4fe4-89bb-22c4d83f1141", "IK Nord"); Storage.newInstance(getApplicationContext()); LocalStorage.newInstance(getApplicationContext()); LocalStorage.getInstance().setServerUrl("http://192.168.1.118:3000/0.0.0/"); LocalStorage.getInstance().setCurrentClub(currentClub.getUuid()); try {/*from w w w .j av a 2 s . c om*/ // TEST Log.d(LOG_TAG, "Media new:"); for (Media media : MediaFilterEngine.apply(Storage.getInstance().getMedia(), MediaStatusNameFilter.newMediaFilterStatus(Media.MEDIA_STATUS_NEW))) { Log.d(LOG_TAG, " * " + media.toString()); } Log.d(LOG_TAG, "Media created:"); for (Media media : MediaFilterEngine.apply(Storage.getInstance().getMedia(), MediaStatusNameFilter.newMediaFilterStatus(Media.MEDIA_STATUS_CREATED))) { Log.d(LOG_TAG, " * " + media.toString()); } Log.d(LOG_TAG, "Media uploaded:"); for (Media media : MediaFilterEngine.apply(Storage.getInstance().getMedia(), MediaStatusNameFilter.newMediaFilterStatus(Media.MEDIA_STATUS_UPLOADED))) { Log.d(LOG_TAG, " * " + media.toString()); } Log.d(LOG_TAG, "Media downloaded:"); for (Media media : MediaFilterEngine.apply(Storage.getInstance().getMedia(), MediaStatusNameFilter.newMediaFilterStatus(Media.MEDIA_STATUS_DOWNLOADED))) { Log.d(LOG_TAG, " * " + media.toString()); } StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); String tag = "com.sandklef.coachapp.fragments.TopFragment"; FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentByTag(tag); if (fragment == null) { fragment = Fragment.instantiate(this, tag); FragmentTransaction ft = fm.beginTransaction(); ft.add(android.R.id.content, fragment, tag); ft.commit(); } topFragment = (TopFragment) fragment; // updateFromServer(); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } } catch (StorageNoClubException e) { e.printStackTrace(); } }
From source file:io.clh.lrt.androidservice.TraceListenerService.java
@Override public void onCreate() { Log.i(TAG, "onCreate()"); // Start up the thread running the service. Note that we create a // separate thread because the service normally runs in the process's // main thread, which we don't want to block. We also make it // background priority so CPU-intensive work will not disrupt our UI. HandlerThread thread = new HandlerThread("ServiceStartArguments"); thread.start();//w w w. j a v a 2s . co m // Get the HandlerThread's Looper and use it for our Handler mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); restClient = new DefaultHttpClient(); //network on main thread H@XXX StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); // Register the LRT receiver IntentFilter filter = new IntentFilter(ACTION_LRT_START); registerReceiver(mLrtReceiver, filter); filter = new IntentFilter(ACTION_LRT_TRACE); registerReceiver(mLrtReceiver, filter); filter = new IntentFilter(ACTION_LRT_STOP); registerReceiver(mLrtReceiver, filter); setNotification("LRT Tracing Service Running", true); infiLoop(); }
From source file:com.isol.app.tracker.Utilita.java
public static JSONObject getJSONObject(String parms) { try {/*from ww w.j av a 2s. co m*/ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); String res = getHttpData(Constants.serviceURL + parms); return new JSONObject(res); } catch (Exception ex) { return null; } }
From source file:sjizl.com.FileUploadTest2.java
@SuppressLint("NewApi") @Override/* ww w .j av a 2 s .co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.fileuploadtest2); //ac_image_grid TextView textView2_under_title; final ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(getApplicationContext())); progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole); progressBar_hole.setVisibility(View.INVISIBLE); right_lin = (LinearLayout) findViewById(R.id.right_lin); middle_lin = (LinearLayout) findViewById(R.id.middle_lin); //right_lin.setBackgroundColor(Color.BLUE); right_lin = (LinearLayout) findViewById(R.id.right_lin); left_lin1 = (LinearLayout) findViewById(R.id.left_lin1); left_lin3 = (LinearLayout) findViewById(R.id.left_lin3); left_lin4 = (LinearLayout) findViewById(R.id.left_lin4); middle_lin = (LinearLayout) findViewById(R.id.middle_lin); textView2_under_title = (TextView) findViewById(R.id.textView2_under_title); ((LinearLayout) textView2_under_title.getParent()).removeView(textView2_under_title); textView2_under_title.setVisibility(View.GONE); ImageView imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard); if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } Button upload_photo0 = (Button) findViewById(R.id.upload_photo0); Button upload_photo1 = (Button) findViewById(R.id.upload_photo1); Button upload_photo2 = (Button) findViewById(R.id.upload_photo2); upload_photo0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "UploadActivity!", Toast.LENGTH_LONG).show(); Intent dashboard = new Intent(getApplicationContext(), UploadActivity.class); startActivity(dashboard); } }); upload_photo1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "FileChooserExampleActivity!", Toast.LENGTH_LONG).show(); Intent dashboard = new Intent(getApplicationContext(), FileChooserExampleActivity.class); startActivity(dashboard); } }); upload_photo2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "FileChooserExampleActivity!", Toast.LENGTH_LONG).show(); Intent dashboard = new Intent(getApplicationContext(), FileChooserExampleActivity.class); startActivity(dashboard); } }); final ImageView left_button; left_button = (ImageView) findViewById(R.id.imageView1_back); Brows(); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //startImagePagerActivity(position); Intent dashboard = new Intent(getApplicationContext(), ProfileActivity.class); dashboard.putExtra("user", naam); dashboard.putExtra("user_foto", foto); dashboard.putExtra("user_foto_num", foto_num); startActivity(dashboard); } }); CommonUtilities u = new CommonUtilities(); u.setHeaderConrols(getApplicationContext(), this, right_lin, left_lin3, left_lin4, left_lin1, left_button); ; }