Android TodoApp with ListView - list don't show up - java

I am writing a simple todo-app and working on the listView. Following the tutorial http://www.vogella.com/tutorials/AndroidListView/article.html#tutorial_ownadapter
My problem is that the list of todos don't show up in the listView. I get no exception or error that indicates it is not working.
I am working with the android sqlite database. When I start the activity, I write objects to the database and read them out, print them in log. So this part is working, you can see in the log.
Then I add the object to my own adapter and set the adapter to the listView.
I don't know what goes wrong. Here is my Project: https://github.com/Visores/de.fhb.android.todoapp/tree/master/MyTodoApp
and here is the log after starting activity the app:
12-06 06:02:46.977: I/ActivityManager(1261): Start proc de.fhb.maus.android.mytodoapp for activity de.fhb.maus.android.mytodoapp/.activities.LoginActivity: pid=2576 uid=10064 gids={50064}
12-06 06:02:47.117: D/dalvikvm(2576): GC_FOR_ALLOC freed 36K, 4% free 3552K/3680K, paused 31ms, total 34ms
12-06 06:02:47.227: D/(2576): HostConnection::get() New Host Connection established 0xb7dc0a70, tid 2576
12-06 06:02:47.247: W/EGL_emulation(2576): eglSurfaceAttrib not implemented
12-06 06:02:47.257: D/OpenGLRenderer(2576): Enabling debug mode 0
12-06 06:02:47.567: I/ActivityManager(1261): Displayed de.fhb.maus.android.mytodoapp/.activities.LoginActivity: +609ms (total +7s839ms)
12-06 06:02:49.237: I/ActivityManager(1261): START u0 {cmp=de.fhb.maus.android.mytodoapp/.activities.TodoOverviewActivity} from pid 2576
12-06 06:02:49.277: D/dalvikvm(2576): GC_FOR_ALLOC freed 105K, 5% free 3960K/4140K, paused 2ms, total 3ms
12-06 06:02:49.287: D/dalvikvm(2576): GC_FOR_ALLOC freed 7K, 3% free 4264K/4368K, paused 2ms, total 2ms
12-06 06:02:49.297: I/dalvikvm-heap(2576): Grow heap (frag case) to 6.654MB for 2536932-byte allocation
12-06 06:02:49.317: D/dalvikvm(2576): GC_FOR_ALLOC freed 1K, 2% free 6740K/6848K, paused 18ms, total 18ms
12-06 06:02:49.387: D/Todos(2576): [Todo [id=1, name=one, description=one, isDone=false, isImportant=true, maturityDate=1231232], Todo [id=2, name=two, description=two, isDone=true, isImportant=true, maturityDate=1231232], Todo [id=3, name=three, description=three, isDone=true, isImportant=false, maturityDate=1231232], Todo [id=4, name=four, description=four, isDone=true, isImportant=true, maturityDate=1231232]]
12-06 06:02:49.427: W/EGL_emulation(2576): eglSurfaceAttrib not implemented
12-06 06:02:49.457: I/ActivityManager(1261): Displayed de.fhb.maus.android.mytodoapp/.activities.TodoOverviewActivity: +220ms
greetings Visores
activity: https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/src/de/fhb/maus/android/mytodoapp/activities/TodoOverviewActivity.java
adapter:
https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/src/de/fhb/maus/android/mytodoapp/adapter/TodoArrayAdapter.java
layout for list row:
https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/res/layout/rowlayout.xml
layout of activity:
https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/res/layout/todo_overview.xml

consider changing
super(context, R.layout.rowlayout);
to
super(context, R.layout.rowlayout,todos);
or override getCount method
#Override
public int getCount() {
// TODO Auto-generated method stub
return todos.size();
}

Related

I want the user to pass my login requirement in order to sign in

I want the intent I have below to be passed only when the user has passed the login requirements. I tried to put an if statement, in the onClick Listener but it wasn't working out. Basically, once the username and password meets my requirements, I want to pass the intent. If the intent doesn't pass, then I want to pass an else statement saying "That user doesn't exist."
10-20 16:53:10.330 2138-2138/com.squarespace.atpublishing.officialworkoutapp
I/art: Not late-enabling -Xcheck:jni (already on)
10-20 16:53:11.510 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 220ms
10-20 16:53:11.640 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 1555(94KB) AllocSpace objects, 0(0B) LOS objects, 33% free, 417KB/623KB, paused 0 total 130ms
10-20 16:53:11.850 2138-2138/com.squarespace.atpublishing.officialworkoutapp W/art: Verification of boolean android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(int, android.view.Menu) took 170ms
10-20 16:53:11.850 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 130ms
10-20 16:53:12.780 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 80ms
10-20 16:53:13.660 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 30ms
10-20 16:53:13.900 2138-2150/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 10ms
10-20 16:53:13.900 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 1031(117KB) AllocSpace objects, 0(0B) LOS objects, 23% free, 781KB/1017KB, paused 10ms total 60ms
10-20 16:53:14.340 2138-2150/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 10ms
10-20 16:53:14.340 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 282(24KB) AllocSpace objects, 0(0B) LOS objects, 13% free, 878KB/1017KB, paused 10ms total 80ms
10-20 16:53:14.460 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background partial concurrent mark sweep GC freed 297(33KB) AllocSpace objects, 0(0B) LOS objects, 36% free, 885KB/1397KB, paused 0 total 120ms
10-20 16:53:14.630 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 16:53:14.900 2138-2229/com.squarespace.atpublishing.officialworkoutapp D/OpenGLRenderer: Render dirty regions requested: true
10-20 16:53:14.950 2138-2138/com.squarespace.atpublishing.officialworkoutapp D/: HostConnection::get() New Host Connection established 0x7fb36d6b8620, tid 2138
10-20 16:53:14.960 2138-2138/com.squarespace.atpublishing.officialworkoutapp D/Atlas: Validating map...
10-20 16:53:15.260 2138-2229/com.squarespace.atpublishing.officialworkoutapp D/: HostConnection::get() New Host Connection established 0x7fb36d6ec100, tid 2229
10-20 16:53:15.350 2138-2229/com.squarespace.atpublishing.officialworkoutapp I/OpenGLRenderer: Initialized EGL, version 1.4
10-20 16:53:15.430 2138-2229/com.squarespace.atpublishing.officialworkoutapp D/OpenGLRenderer: Enabling debug mode 0
10-20 16:53:15.440 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/EGL_emulation: eglSurfaceAttrib not implemented
10-20 16:53:15.440 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb36d6b7b00, error=EGL_SUCCESS
10-20 16:53:15.620 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 30ms
10-20 16:53:15.650 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 39 frames! The application may be doing too much work on its main thread.
10-20 16:53:20.900 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 40ms
10-20 16:53:20.930 2138-2150/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 16:53:21.510 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 190ms
10-20 16:53:21.660 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 102 frames! The application may be doing too much work on its main thread.
10-20 12:53:24.100 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 278(36KB) AllocSpace objects, 0(0B) LOS objects, 11% free, 1242KB/1397KB, paused 0 total 190ms
10-20 12:53:25.100 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 70ms
10-20 12:53:26.510 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 30ms
10-20 12:53:27.000 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 12:53:27.330 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 149 frames! The application may be doing too much work on its main thread.
10-20 12:53:27.770 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/EGL_emulation: eglSurfaceAttrib not implemented
10-20 12:53:27.770 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb36d2e6900, error=EGL_SUCCESS
10-20 12:53:28.120 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 47 frames! The application may be doing too much work on its main thread.
10-20 12:53:28.220 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/EGL_emulation: eglSurfaceAttrib not implemented
10-20 12:53:28.220 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb36d2e69c0, error=EGL_SUCCESS
10-20 12:53:28.270 2138-2138/com.squarespace.atpublishing.officialworkoutapp W/View: requestLayout() improperly called by android.support.design.internal.NavigationMenuView{2c5956e4 VFED.VC. ......ID 0,0-384,800} during layout: running second layout pass
10-20 12:53:28.460 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 12:53:29.040 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 38 frames! The application may be doing too much work on its main thread.
`
Button mEmailSignInButton = (Button)
findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
attemptLogin();
if (mPasswordView.getText().toString().isEmpty() && mEmailSignInButton.getText().toString().isEmpty()){
Snackbar.make(view, "You Didn't enter anything", Snackbar.LENGTH_LONG).setAction("Action", null);
} else {
Intent intent = new Intent(LoginActivity.this, DrawerActivity.class);
startActivity(intent);
}
Intent intent = new Intent(LoginActivity.this, DrawerActivity.class);
startActivity(intent);
}
});
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
private void attemptLogin() {
if (mAuthTask != null) {
return;
}
// Reset errors.
mEmailView.setError(null);
mPasswordView.setError(null);
// Store values at the time of the login attempt.
String email = mEmailView.getText().toString();
String password = mPasswordView.getText().toString();
boolean cancel = false;
View focusView = null;
// Check for a valid password, if the user entered one.
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
mPasswordView.setError(getString(R.string.error_invalid_password));
focusView = mPasswordView;
cancel = true;
}
// Check for a valid email address.
if (TextUtils.isEmpty(email)) {
mEmailView.setError(getString(R.string.error_field_required));
focusView = mEmailView;
cancel = true;
} else if (!isEmailValid(email)) {
mEmailView.setError(getString(R.string.error_invalid_email));
focusView = mEmailView;
cancel = true;
}
if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus();
} else {
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
showProgress(true);
mAuthTask = new UserLoginTask(email, password);
mAuthTask.execute((Void) null)
}
}
Your attemptLogin(); needs to be called within the else { } of your if.
Currently, it's being called before your if, so it will attempt to login even if your email or password fields are empty.
This was probably just an oversight on your part. If not, you might want to brush on Java by doing the exercises on the following web site. http://codingbat.com/java

I can't load image and text in some platform from res/raw

I have layout that my images and text files in "res/raw" folder are load by user search.
image's name start with ("p"+month+"_"+day) and the text file start with "t".
when user search date java create file name by month and day.
but this is not show image and text on the some platform like tablet 10" & sony xperia T
Image
String MD = (jCal.toString().substring(5)); // 2014-03-25 => 03-25
String[] Split_MD = MD.split("-");
String mDrawableName = ("p"+Split_MD[0]+"_"+Split_MD[1]);
ImageView Pic = (ImageView) findViewById(R.id.imageView);
Resources res = getResources();
int resId = res.getIdentifier(mDrawableName, "raw", getPackageName());
Pic.setImageResource(resId);
Text
TextView txtContent = (TextView) findViewById(R.id.date);
String mAssetsName = ("raw/t"+Split_MD[0]+"_"+Split_MD[1]);
txtContent.setTypeface(face);
try {
Resources res1 = getResources();
InputStream in_s = res1.openRawResource(getResources().getIdentifier(mAssetsName,"raw", getPackageName()));
byte[] b = new byte[in_s.available()];
in_s.read(b);
txtContent.setText(new String(b));
} catch (Exception e) {
// e.printStackTrace();
txtContent.setText("Error: can't show help.");
}
Logcat:
D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
E/Trace﹕ error opening trace file: No such file or directory (2)
D/dalvikvm﹕ GC_FOR_ALLOC freed 39K, 7% free 2430K/2592K, paused 72ms, total 77ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 3.075MB for 614416-byte allocation
D/dalvikvm﹕ GC_FOR_ALLOC freed 1K, 6% free 3029K/3196K, paused 66ms, total 66ms
D/dalvikvm﹕ GC_CONCURRENT freed <1K, 6% free 3029K/3196K, paused 8ms+5ms, total 90ms
D/gralloc_goldfish﹕ Emulator without GPU emulation detected.
I/Choreographer﹕ Skipped 32 frames! The application may be doing too much work on its main thread.
I/Choreographer﹕ Skipped 68 frames! The application may be doing too much work on its main thread.
D/dalvikvm﹕ GC_FOR_ALLOC freed 21K, 5% free 3184K/3328K, paused 253ms, total 273ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 3.810MB for 614416-byte allocation
D/dalvikvm﹕ GC_CONCURRENT freed 4K, 4% free 3779K/3932K, paused 12ms+69ms, total 253ms
I/Choreographer﹕ Skipped 42 frames! The application may be doing too much work on its main thread.

Android EditBox responses slow when entering data

I am testing my android application on Galaxy S3. I have a form having views like Edit Box, radios, drop down.. When I edit any EditText the keyboard responses slow. When I run the form separately it performs fine.
Here is logs of LogCat
07-26 12:39:46.925: D/SensorManager(3165): unregisterListener:: Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht#,*b(a+e8
07-26 12:39:46.925: I/SensorManager(3165): Set min delay = 200000
07-26 12:39:46.925: I/SensorManager(3165): Before sending... delay = 200000
07-26 12:39:46.925: D/Sensors(3165): Remain listener = android.view.OrientationEventListener$SensorEventListenerImpl#419e6320
07-26 12:39:46.925: I/Sensors(3165): sendDelay --- 200000000
07-26 12:39:46.955: D/SensorManager(3165): JNI - sendDelay
07-26 12:39:46.985: D/SensorManager(3165): registerListener :: handle = 0 name= MPU-6050 Accelerometer delay= 200000 Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht#,))b..,8
07-26 12:39:47.015: W/IInputConnectionWrapper(3165): getSelectedText on inactive InputConnection
07-26 12:39:47.045: W/IInputConnectionWrapper(3165): setComposingText on inactive InputConnection
07-26 12:39:47.045: W/IInputConnectionWrapper(3165): getExtractedText on inactive InputConnection
07-26 12:39:48.446: D/dalvikvm(3165): GC_CONCURRENT freed 1974K, 17% free 17467K/20999K, paused 3ms+56ms, total 175ms
07-26 12:39:50.428: D/dalvikvm(3165): GC_CONCURRENT freed 2035K, 17% free 17440K/20999K, paused 3ms+54ms, total 174ms
07-26 12:39:52.590: D/dalvikvm(3165): GC_CONCURRENT freed 2003K, 17% free 17442K/20999K, paused 15ms+32ms, total 166ms
07-26 12:39:55.843: D/dalvikvm(3165): GC_CONCURRENT freed 1998K, 17% free 17455K/20999K, paused 13ms+48ms, total 181ms
TabActivity is deprecated in android jelly bean that is cause of slowness of keyboard. so I have removed it works fine than.

Facebook login crash with no error (Parse.com) android

My app crashes when I am trying to login with parse.com facebook login. I tried to debug and found out that the code never gets the callback, here is the login code:
ParseFacebookUtils.logIn(thisActivity, new LogInCallback() {
#Override
public void done(ParseUser user, ParseException err) {
if (user == null) { // the code never gets here
Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
Log.d("MyApp", "User signed up and logged in through Facebook!");
} else {
Log.d("MyApp", "User logged in through Facebook!");
}
}
});
here is the logcat (couldn't find any error):
06-24 21:04:39.760: D/dalvikvm(2634): GC_FOR_ALLOC freed 80K, 7% free 2612K/2796K, paused 26ms, total 28ms
06-24 21:04:39.760: I/dalvikvm-heap(2634): Grow heap (frag case) to 3.107MB for 480016-byte allocation
06-24 21:04:39.830: D/dalvikvm(2634): GC_FOR_ALLOC freed <1K, 6% free 3080K/3268K, paused 64ms, total 64ms
06-24 21:04:39.850: D/dalvikvm(2634): GC_CONCURRENT freed <1K, 6% free 3082K/3268K, paused 4ms+2ms, total 23ms
06-24 21:04:39.990: D/libEGL(2634): loaded /system/lib/egl/libEGL_tegra.so
06-24 21:04:39.990: E/(2634): file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt: not found!
06-24 21:04:39.990: I/(2634): Attempting to load EGL implementation /system/lib//egl/libEGL_tegra_impl
06-24 21:04:40.000: I/(2634): Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl
06-24 21:04:40.000: D/libEGL(2634): loaded /system/lib/egl/libGLESv1_CM_tegra.so
06-24 21:04:40.000: D/libEGL(2634): loaded /system/lib/egl/libGLESv2_tegra.so
06-24 21:04:40.060: I/(2634): Loading GLESv2 implementation /system/lib//egl/libGLESv2_tegra_impl
06-24 21:04:40.060: D/OpenGLRenderer(2634): Enabling debug mode 0
06-24 21:04:40.390: D/dalvikvm(2634): GC_CONCURRENT freed 247K, 10% free 3257K/3608K, paused 4ms+3ms, total 25ms
06-24 21:04:40.940: D/TextView(2634): Constructor - Got Res id for appearance for textColorPrimaryInverse
06-24 21:04:40.940: W/ResourceType(2634): Skipping entry 0x1060001 in package table 0 because it is not complex!
06-24 21:04:40.940: D/TextView(2634): Constructor - Got appearance for textColorPrimaryInverse
06-24 21:04:40.940: D/TextView(2634): Constructor -- Got mEditTextBackgroundColor
06-24 21:04:40.970: D/TextView(2634): Constructor - Got Res id for appearance for textColorPrimaryInverse
06-24 21:04:40.970: W/ResourceType(2634): Skipping entry 0x1060001 in package table 0 because it is not complex!
06-24 21:04:40.970: D/TextView(2634): Constructor - Got appearance for textColorPrimaryInverse
06-24 21:04:40.970: D/TextView(2634): Constructor -- Got mEditTextBackgroundColor
06-24 21:04:40.990: D/dalvikvm(2634): GC_FOR_ALLOC freed 222K, 9% free 3381K/3708K, paused 21ms, total 21ms
06-24 21:04:40.990: I/dalvikvm-heap(2634): Grow heap (frag case) to 3.858MB for 480016-byte allocation
06-24 21:04:41.010: D/dalvikvm(2634): GC_FOR_ALLOC freed <1K, 8% free 3849K/4180K, paused 19ms, total 19ms
06-24 21:04:41.030: D/dalvikvm(2634): GC_CONCURRENT freed 32K, 9% free 3818K/4180K, paused 2ms+2ms, total 16ms
06-24 21:04:41.050: D/dalvikvm(2634): GC_FOR_ALLOC freed <1K, 9% free 3818K/4180K, paused 13ms, total 13ms
06-24 21:04:41.050: I/dalvikvm-heap(2634): Grow heap (frag case) to 4.285MB for 480016-byte allocation
06-24 21:04:41.060: D/dalvikvm(2634): GC_FOR_ALLOC freed 0K, 8% free 4287K/4652K, paused 16ms, total 16ms
06-24 21:04:41.080: D/dalvikvm(2634): GC_CONCURRENT freed <1K, 8% free 4287K/4652K, paused 1ms+1ms, total 15ms
EDIT
*EDIT:*
I think I found the source of the problem, when I am trying to access the declaration of logIn of ParseFacebookUtils I am getting this page: Class File editor (the jar of this class file belongs to container 'android dependencies' which does not allow modification to source attachments on its entries.).
Also I have updated my parse sdk version from 1.2.4 to 1.3 by deleting the old sdk from libs and adding the new one with it's content (total of 4 files and folder).
Why the app crashes? why there is no error?? Thanks for any help.
Try to clear logcat/clear project and restart eclipse, sometimes thats the reason that no error is being shown up
The problem was with my Manifest (some wrong properties).

SSID vs BSSID: Connecting to Wifi via Android Programatically / Using WifiManager to connect to a network

I hear some developers are unable to connect to wifi when specifiying the SSID:
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/di4gMhC0ZTY
However other developers are connecting via the SSID:
How do I connect to a specific Wi-Fi network in Android programmatically?
Which method should be used?
I currently cannot connect.
SOURCE:
import java.util.List;
import android.app.Activity;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.content.Context;
public class Connect extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.connect);
String networkSSID = "ANDRE-PC_NETWORK";
String networkPass = "superman";
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\""; //ssid must be in quotes
conf.wepKeys[0] = "\"" + networkPass + "\"";
conf.wepTxKeyIndex = 0;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
conf.preSharedKey = "\""+ networkPass +"\"";
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
wifiManager.addNetwork(conf);
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
for( WifiConfiguration i : list ) {
if(i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {
wifiManager.disconnect();
wifiManager.enableNetwork(i.networkId, true);
wifiManager.reconnect();
break;
}
}
}}
LOGCAT:
04-04 12:05:11.843: I/ActivityManager(479): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.wifi.connect/.Connect} from pid 2785
04-04 12:05:11.873: D/Finsky(1555): [159] ConsumptionAppServiceConn.getDataFromService: retrieved 20 documents from [2]
04-04 12:05:11.923: D/dalvikvm(479): GC_FOR_ALLOC freed 2477K, 23% free 17481K/22424K, paused 59ms, total 60ms
04-04 12:05:11.943: D/AndroidRuntime(2785): Shutting down VM
04-04 12:05:11.953: D/dalvikvm(2795): Late-enabling CheckJNI
04-04 12:05:11.953: D/dalvikvm(2785): GC_CONCURRENT freed 96K, 17% free 500K/600K, paused 0ms+0ms, total 3ms
04-04 12:05:11.953: D/jdwp(2785): Got wake-up signal, bailing out of select
04-04 12:05:11.953: D/dalvikvm(2785): Debugger has detached; object registry had 1 entries
04-04 12:05:11.953: I/ActivityManager(479): Start proc com.wifi.connect for activity com.wifi.connect/.Connect: pid=2795 uid=10110 gids={50110, 3003, 1028}
04-04 12:05:12.073: D/dalvikvm(785): GC_FOR_ALLOC freed 2349K, 25% free 18097K/24032K, paused 40ms, total 40ms
04-04 12:05:12.073: D/Finsky(1555): [1] ConsumptionAppDataCache.setConsumptionAppData: data didn't change for backend=[2], ignoring!
04-04 12:05:12.093: D/dalvikvm(479): GC_CONCURRENT freed 2628K, 24% free 17135K/22424K, paused 3ms+24ms, total 171ms
04-04 12:05:12.143: D/dalvikvm(2795): GC_FOR_ALLOC freed 74K, 3% free 7379K/7580K, paused 19ms, total 19ms
04-04 12:05:12.163: I/dalvikvm-heap(2795): Grow heap (frag case) to 10.841MB for 3686416-byte allocation
04-04 12:05:12.193: D/dalvikvm(2795): GC_FOR_ALLOC freed 1K, 2% free 10977K/11184K, paused 30ms, total 30ms
04-04 12:05:12.233: D/dalvikvm(2795): GC_CONCURRENT freed <1K, 2% free 10977K/11184K, paused 4ms+3ms, total 41ms
04-04 12:05:12.363: D/dalvikvm(785): GC_FOR_ALLOC freed 2349K, 25% free 18097K/24032K, paused 49ms, total 49ms
04-04 12:05:12.393: D/dalvikvm(479): GC_CONCURRENT freed 2439K, 24% free 17143K/22424K, paused 14ms+13ms, total 184ms
04-04 12:05:12.503: D/dalvikvm(785): GC_FOR_ALLOC freed 2349K, 25% free 18097K/24032K, paused 28ms, total 28ms
04-04 12:05:12.533: D/dalvikvm(479): GC_CONCURRENT freed 2423K, 24% free 17098K/22424K, paused 3ms+9ms, total 100ms
04-04 12:05:12.533: D/dalvikvm(479): WAIT_FOR_CONCURRENT_GC blocked 1ms
04-04 12:05:12.543: D/dalvikvm(2795): GC_FOR_ALLOC freed <1K, 2% free 10977K/11184K, paused 18ms, total 18ms
04-04 12:05:12.563: I/dalvikvm-heap(2795): Grow heap (frag case) to 17.067MB for 6529744-byte allocation
04-04 12:05:12.583: D/dalvikvm(2795): GC_FOR_ALLOC freed 0K, 2% free 17353K/17564K, paused 19ms, total 19ms
04-04 12:05:12.613: D/dalvikvm(2795): GC_CONCURRENT freed <1K, 2% free 17353K/17564K, paused 4ms+12ms, total 37ms
04-04 12:05:12.623: D/dalvikvm(2333): GC_CONCURRENT freed 174K, 6% free 7846K/8304K, paused 10ms+37ms, total 71ms
04-04 12:05:12.633: D/dalvikvm(785): GC_FOR_ALLOC freed 2349K, 25% free 18097K/24032K, paused 37ms, total 37ms
04-04 12:05:12.643: D/dalvikvm(479): GC_CONCURRENT freed 2359K, 24% free 17093K/22424K, paused 4ms+10ms, total 97ms
04-04 12:05:12.663: I/ActivityManager(479): Start proc com.android.keychain for broadcast com.android.keychain/.KeyChainBroadcastReceiver: pid=2819 uid=1000 gids={41000, 1015, 1028, 3002, 3001, 3003, 3007}
04-04 12:05:12.703: W/ContextImpl(2819): Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1352 android.content.ContextWrapper.startService:450 android.content.ContextWrapper.startService:450 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2376
04-04 12:05:12.753: I/ActivityManager(479): Start proc com.google.android.googlequicksearchbox for broadcast com.google.android.googlequicksearchbox/com.google.android.apps.sidekick.GmmLocationProviderImpl$GmmPackageWatcher: pid=2837 uid=10055 gids={50055, 3003, 1028, 1007, 3002, 1015, 1006}
04-04 12:05:12.793: I/ActivityManager(479): No longer want com.google.android.gms (pid 2258): empty #17
04-04 12:05:12.823: I/ActivityManager(479): Start proc com.google.android.partnersetup for content provider com.google.android.partnersetup/.RlzAppProvider: pid=2854 uid=10025 gids={50025, 3003, 1028}
04-04 12:05:12.853: D/GStaticConfiguration(2837): #loadConfiguration
04-04 12:05:12.873: D/GStaticConfiguration(2837): #loadConfiguration from preference
04-04 12:05:12.883: E/wpa_supplicant(594): Line 0: Invalid WEP key length 8 - this network block will be ignored
04-04 12:05:12.913: D/dalvikvm(2837): GC_CONCURRENT freed 233K, 5% free 7558K/7916K, paused 4ms+2ms, total 45ms
04-04 12:05:12.913: D/dalvikvm(2837): WAIT_FOR_CONCURRENT_GC blocked 8ms
04-04 12:05:12.913: D/dalvikvm(2837): WAIT_FOR_CONCURRENT_GC blocked 8ms
04-04 12:05:12.913: D/dalvikvm(2837): WAIT_FOR_CONCURRENT_GC blocked 9ms
04-04 12:05:12.913: W/GAV2(2837): Thread[main,5,main]: Connection to service failed 1
04-04 12:05:12.913: W/ActivityManager(479): Unable to start service Intent { act=com.google.android.gms.analytics.service.START (has extras) } U=0: not found
04-04 12:05:12.923: I/wpa_supplicant(594): wlan0: CTRL-EVENT-DISCONNECTED bssid=20:4e:7f:08:61:e6 reason=3 locally_generated=1
04-04 12:05:12.933: D/GStaticConfiguration(2837): Configuration loaded [70]
04-04 12:05:12.933: W/GAV2(2837): Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
04-04 12:05:12.933: D/CommandListener(123): Clearing all IP addresses on wlan0
04-04 12:05:12.943: D/ConnectivityService(479): ConnectivityChange for WIFI: DISCONNECTED/DISCONNECTED
04-04 12:05:12.943: D/ConnectivityService(479): Attempting to switch to BLUETOOTH_TETHER
04-04 12:05:12.943: D/ConnectivityService(479): Attempting to switch to ETHERNET
04-04 12:05:12.963: D/NetUtils(479): android_net_utils_resetConnections in env=0x68afd138 clazz=0x3e400001 iface=wlan0 mask=0x3
04-04 12:05:12.963: D/ConnectivityService(479): resetConnections(wlan0, 3)
04-04 12:05:12.973: W/Smack/Packet(898): notify conn break (IOEx), close connection
04-04 12:05:12.973: W/Sidekick_LocationOracleImpl(2837): Best location was null
04-04 12:05:12.973: I/ActivityManager(479): Start proc jp.co.omronsoft.iwnnime.ml for broadcast jp.co.omronsoft.iwnnime.ml/.UninstallReceiver: pid=2883 uid=10062 gids={50062, 1028}
04-04 12:05:12.993: D/ConnectivityService(479): ConnectivityChange for WIFI: DISCONNECTED/DISCONNECTED
04-04 12:05:12.993: D/ConnectivityService(479): Attempting to switch to BLUETOOTH_TETHER
04-04 12:05:12.993: D/ConnectivityService(479): Attempting to switch to ETHERNET
04-04 12:05:12.993: D/NetUtils(479): android_net_utils_resetConnections in env=0x68afd138 clazz=0x40a00001 iface=wlan0 mask=0x3
04-04 12:05:12.993: D/ConnectivityService(479): resetConnections(wlan0, 3)
04-04 12:05:12.993: I/ActivityManager(479): No longer want com.google.android.calendar (pid 2122): empty #17
04-04 12:05:12.993: I/ActivityManager(479): No longer want com.android.providers.calendar (pid 2142): empty #17
04-04 12:05:13.083: I/ActivityManager(479): No longer want com.google.android.talk (pid 2217): empty #17
04-04 12:05:13.113: I/ActivityManager(479): Start proc com.google.android.gms for broadcast com.google.android.gms/.common.receiver.SystemBroadcastReceiver: pid=2900 uid=10021 gids={50021, 3003, 1007, 1028, 1015, 2001, 3006}
04-04 12:05:13.113: I/ActivityManager(479): Displayed com.wifi.connect/.Connect: +1s174ms
04-04 12:05:13.123: I/qtaguid(898): Failed write_ctrl(u 50) res=-1 errno=22
04-04 12:05:13.123: I/qtaguid(898): Untagging socket 50 failed errno=-22
04-04 12:05:13.123: W/NetworkManagementSocketTagger(898): untagSocket(50) failed with errno -22
04-04 12:05:13.123: D/ConnectivityService(479): handleInetConditionChange: no active default network - ignore
04-04 12:05:13.193: D/dalvikvm(2900): Trying to load lib /data/app-lib/com.google.android.gms-2/libAppDataSearch.so 0x426085b0
04-04 12:05:13.203: D/dalvikvm(2900): Added shared lib /data/app-lib/com.google.android.gms-2/libAppDataSearch.so 0x426085b0
04-04 12:05:13.203: D/dalvikvm(2900): No JNI_OnLoad found in /data/app-lib/com.google.android.gms-2/libAppDataSearch.so 0x426085b0, skipping init
04-04 12:05:13.213: D/Icing(2900): Init last flush num docs 0 last docstore size 0
04-04 12:05:13.213: D/Icing(2900): Docid map file has no data, nothing to scan
04-04 12:05:13.213: D/Icing(2900): File /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.perdocdata contains 0 records of size 6
04-04 12:05:13.213: D/Icing(2900): Init docstore ok num docs 0 bytes 0
04-04 12:05:13.263: V/Icing(2900): Lite index crc computed in 0.101ms
04-04 12:05:13.263: V/Icing(2900): Lite index init ok in 4.994ms
04-04 12:05:13.263: V/Icing(2900): Warming lite-index took 0.007ms
04-04 12:05:13.263: V/Icing(2900): Warming lexicon took 0.005ms
04-04 12:05:13.263: V/Icing(2900): Warming display mappings took 0.004ms
04-04 12:05:13.263: D/Icing(2900): Init index ok num docs 0
04-04 12:05:13.263: D/Icing(2900): Init done
P.S.
All I want to do is establish a connection to a specific wifi network. If anyone knows where to find a working copy of some source code which will do this which I can test - it may just resolve all my issues (the only post I've been able to find is the one shown above from S.O. and it isnt working)
You can try this way
conf.SSID = "\" + networkSSID + \""; //ssid must be in quotes
conf.wepKeys[0] = "\" + networkPass + \"";

Categories

Resources