My application won't run anymore in my tablet and I don't know why. It runs fine in the emulator.
public class TestingActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
String uname, pass, pic;
EditText txtUname, txtPass;
Button login;
TextView result, tview2, tview3;
String nameStartLine = " <td style=\"font:10px verdana; color:#312e25; text-align:right;\">Name:</td>";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
login=(Button)findViewById(R.id.button1);
result=(TextView)findViewById(R.id.textView1);
tview2=(TextView)findViewById(R.id.textView2);
tview3=(TextView)findViewById(R.id.textView3);
txtUname=(EditText)findViewById(R.id.editText1);
txtPass=(EditText)findViewById(R.id.editText2);
login.setOnClickListener(this);
android.view.Display display = ((android.view.WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
//set width and height
txtUname.setHeight((int)(display.getHeight()*0.079));
txtUname.setWidth((int)(display.getWidth()/1.2));
txtPass.setHeight((int)(display.getHeight()*0.079));
txtPass.setWidth((int)(display.getWidth()/1.2));
login.setHeight((int)(display.getHeight()*0.079));
login.setWidth((int)(display.getWidth()/3.2));
//set position
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams lp3 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp1.setMargins((int) display.getWidth()/11, (int) ((int) display.getHeight()/3), 0, 0);
lp2.setMargins((int) display.getWidth()/11, (int) ((int) display.getHeight()/2.1), 0, 0);
lp3.setMargins((int) (display.getWidth()/2.7), (int) ((int) display.getHeight()/1.7), 0, 0);
lp4.setMargins((int) display.getWidth()/11, (int) ((int) display.getHeight()/3.4), 0, 0);
lp5.setMargins((int) display.getWidth()/11, (int) ((int) display.getHeight()/2.3), 0, 0);
txtUname.setLayoutParams(lp1);
txtPass.setLayoutParams(lp2);
tview2.setLayoutParams(lp4);
tview3.setLayoutParams(lp5);
login.setLayoutParams(lp3);
}
public void postLoginData()
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://students.usls.edu.ph/login.cfm");
try {
String username = txtUname.getText().toString();
String password = txtPass.getText().toString();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username",username));
nameValuePairs.add(new BasicNameValuePair("password",password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
String str = inputStreamToString(response.getEntity().getContent()).toString();
result.setText(str);
Intent intent = new Intent(TestingActivity.this,panel_1.class);
intent.putExtra("result",result.getText());
pic = "http://teachers.usls.edu.ph/student_pics/" + txtUname.getText() + ".jpg";
intent.putExtra("pic",pic);
startActivity(intent);
}
catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private StringBuilder inputStreamToString(InputStream is) {
String line = "";
StringBuilder total = new StringBuilder();
// Wrap a BufferedReader around the InputStream
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
// Read response until the end
try{
while ((line = rd.readLine()) != null) {
if (line.equals(nameStartLine))
{
line = rd.readLine();
StringTokenizer st = new StringTokenizer(line, ">< ");
String marker = st.nextToken();
while(st.hasMoreTokens())
{
if(marker.equals("strong"))
{
marker = st.nextToken();
while(!(marker.equals("/strong")))
{
total.append(marker + " ");
marker = st.nextToken();
}
}
marker = st.nextToken();
}
}
}
}
catch (IOException e) {
e.printStackTrace();
}
return total;
}
public void onClick(View view) {
if(view == login){
postLoginData();
}
}
}
The panel class:
public class panel_1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
TextView result = (TextView)findViewById(R.id.txtresult);
result.setText(""+getIntent().getExtras().getString("result"));
WebView myWebView = (WebView) findViewById(R.id.webView1);
myWebView.loadUrl(getIntent().getExtras().getString("pic"));
android.view.Display display = ((android.view.WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
}
}