@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.classes); setcc(); Log.e("n", " CC Activity Started"); try { Class<?> strictModeClass = Class.forName( "android.os.StrictMode", true, Thread.currentThread().getContextClassLoader()); Class<?> threadPolicyClass = Class.forName( "android.os.StrictMode$ThreadPolicy", true, Thread.currentThread().getContextClassLoader()); Class<?> threadPolicyBuilderClass = Class.forName( "android.os.StrictMode$ThreadPolicy$Builder", true, Thread.currentThread().getContextClassLoader()); Method setThreadPolicyMethod = strictModeClass.getMethod("setThreadPolicy", threadPolicyClass); Method detectAllMethod = threadPolicyBuilderClass.getMethod("detectAll"); Method penaltyMethod = threadPolicyBuilderClass.getMethod("penaltyLog"); Method buildMethod = threadPolicyBuilderClass.getMethod("build"); Constructor<?> threadPolicyBuilderConstructor = threadPolicyBuilderClass.getConstructor(); Object threadPolicyBuilderObject = threadPolicyBuilderConstructor.newInstance(); Object obj = detectAllMethod.invoke(threadPolicyBuilderObject); obj = penaltyMethod.invoke(obj); Object threadPolicyObject = buildMethod.invoke(obj); setThreadPolicyMethod.invoke(strictModeClass, threadPolicyObject); } catch (Exception ex) { Log.w("n", "Strict not enabled...."); } final Button button = (Button) findViewById(R.id.ccbutton1); button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { setcc(); } }); }
@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(this); setContentView(R.layout.main); inputView = (EditText) findViewById(R.id.input_view); inputView.setOnEditorActionListener(this); listAdapter = new ArrayAdapter<String>(this, R.layout.row); listAdapter.setNotifyOnChange(true); resultsView = (ListView) this.findViewById(R.id.results_view); resultsView.setAdapter(listAdapter); resultsView.setOnItemClickListener(this); }