<activity
android:label="@string/app_name"
- android:name=".NextActivity" >
+ android:name=".NextActivity"
+ android:theme="@android:style/Theme.Black"
+ android:screenOrientation="portrait"
+ android:configChanges="touchscreen|keyboard"
+ android:permission="android.permission.INTERNET">
+ <intent-filter>
+ <action android:name="android.intent.action.RUN"/>
+ </intent-filter>
</activity>
</application>
CookieManager.getInstance().setCookie("192.168.1.34/userfront.php",cookie);
CookieSyncManager.getInstance().sync();
//OK GO TO THE NEXT ACTIVITY
- Intent i = new Intent(this.context, NextActivity.class);
- this.context.startActivity(i);
+ this.context.startActivity(new Intent(Intent.ACTION_RUN));
break;
case HttpStatus.SC_UNAUTHORIZED:
//ERROR IN USERNAME OR PASSWORD
package de.android.test1;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.http.HttpEntity;
+import java.util.concurrent.ExecutionException;
+
import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.message.BasicNameValuePair;
+
import android.app.Activity;
import android.content.Intent;
-import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
+import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
-import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.widget.EditText;
public class Test1Activity extends Activity {
-
+ private static final String TAG = "Test1Activity";
/** Called when the activity is first created. */
@Override
// TODO Auto-generated catch block
e.printStackTrace();
}
- new MobieAdHttpAuthClient(username.getText().toString(), password.getText().toString(), this).execute(url);
+ new MobieAdHttpAuthClient(username.getText().toString(), password.getText().toString(), this).execute(url);
}
public void onClickCancel(View v) {
<activity
android:label="@string/app_name"
- android:name=".NextActivity" >
+ android:name=".NextActivity"
+ android:theme="@android:style/Theme.Black"
+ android:screenOrientation="portrait"
+ android:configChanges="touchscreen|keyboard"
+ android:permission="android.permission.INTERNET">
+ <intent-filter>
+ <action android:name="android.intent.action.RUN"/>
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
</application>
}
public static final class layout {
public static final int main=0x7f030000;
+ public static final int main2=0x7f030001;
}
public static final class string {
public static final int app_name=0x7f040001;
<FrameLayout
android:id="@+id/frameLayout1"
- android:layout_width="match_parent" android:layout_height="70dp">
+ android:layout_width="match_parent"
+ android:layout_height="70dp">
</FrameLayout>
<EditText
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
+import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
public class Test2Activity extends Activity {
private static final String TAG = "Test2Activity";
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
final String URLAuth = "http://192.168.1.34/userfront.php/api/login/auth.json";
final EditText password = (EditText) findViewById(R.id.password);
final EditText username = (EditText) findViewById(R.id.username);
-
- HttpClient httpClient = new DefaultHttpClient();
- HttpPost httpPost = new HttpPost(URLAuth);
+ final HttpClient httpClient = new DefaultHttpClient();
+ final HttpPost httpPost = new HttpPost(URLAuth);
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
try {
httpEntity = new UrlEncodedFormEntity(nameValuePairs);
} catch (UnsupportedEncodingException e) {
- Log.e(TAG, "Error while encoding POST parameters." + e);
+ Log.e(TAG, "Error while encoding POST parameters.", e);
}
httpPost.setEntity(httpEntity);
httpPost.setHeader("User-Agent", "MobieAds/1.0");
try {
httpResponse = httpClient.execute(httpPost);
- } catch (ClientProtocolException e1) {
- Log.e(TAG, "Error while executing HTTP client connection.");
- } catch (IOException e1) {
- Log.e(TAG, "Error while executing HTTP client connection.");
+ } catch (ClientProtocolException e) {
+ Log.e(TAG, "Error while executing HTTP client connection.", e);
+ } catch (IOException e) {
+ Log.e(TAG, "Error while executing HTTP client connection.", e);
}
if (httpResponse != null)
String cookie = httpResponse.getLastHeader("Set-Cookie").getValue();
CookieManager.getInstance().setCookie("192.168.1.34/userfront.php",cookie);
CookieSyncManager.getInstance().sync();
- //OK GO TO THE NEXT ACTIVITY
+ //OK GO TO THE MAIN ACTIVITY
+ this.startActivity(new Intent(Intent.ACTION_RUN));
break;
case HttpStatus.SC_UNAUTHORIZED:
//ERROR IN USERNAME OR PASSWORD
Log.e(TAG, "Error while retrieving the HTTP status line.");
break;
}
- }
- String myCookie = CookieManager.getInstance().getCookie("192.168.1.34/userfront.php");
- Log.e("hola", "Error while retrieving the HTTP status line." + myCookie);
-
+ }
}
public void onClickCancel(View v) {