Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Threads not executing
    text
    copied!<p>So yeah, my thread isn't executing, or doing the code within it. I just wanted to run a shell script from my sdcard, and show a "loading" circles or "progress" circle or whatever you want to call it. When I click the button to run the thread, I get the progress/loading bar/circle, but it just sits there and does nothing. I've looked at some examples but still cannot figure out what I did wrong. Here's my code:</p> <pre><code>package com.cydeon.plasmamodz; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.TimeoutException; import com.stericson.RootTools.*; import com.stericson.RootTools.exceptions.RootDeniedException; import com.stericson.RootTools.execution.CommandCapture; import android.app.Activity; import android.app.ProgressDialog; import android.content.res.AssetManager; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; public class Install extends Activity{ private static ProgressDialog progressDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.install); Button bInstall = (Button) findViewById(R.id.bInstallTheme); bInstall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { showDialog(); } }); } public void showDialog(){ progressDialog = ProgressDialog.show(Install.this, "", "Installing Theme", true); Thread thread = new Thread(); thread.start(); } public void run(){ try{ Thread.sleep(1000); CommandCapture command = new CommandCapture(0, "su", "sh /sdcard/plasma/scripts/install.sh"); try { RootTools.getShell(true).add(command).waitForFinish(); } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (TimeoutException e) { e.printStackTrace(); } catch (RootDeniedException e) { e.printStackTrace(); } }catch (InterruptedException e){ e.printStackTrace(); } handler.sendEmptyMessage(0); } private static Handler handler = new Handler() { @Override public void handleMessage(Message msg) { progressDialog.dismiss(); } }; } </code></pre> <p>So, am I doing something wrong? Why won't it run my code? Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload