Tuesday, April 16, 2013

[android help] Android listview adapter with button


I have a problem with my Android application which I'm developing in C#. I have a ListActivity and an ArrayAdapter and inside ListActivity i have custom views with a TextView and a Button. This button should start new activities, get the results from the activities (mostly text inputs), and do something in the background, and then update the TextView's text.


I'm using ViewHolder pattern in the ArrayAdapter, and Command Pattern for the background operations.


My problem is that I can't find a way how to update the TextViews inside ArrayAdapter, since I have the results of the activities in the ListActivity. I tried to create an event in ListActivity and subscribed to it inside ArrayAdapter but I think it is not an optimal solution to this problem.


Could you suggest something better implementation to this problem?


Thanks in advance!



.

stackoverflow.comm

[General] Exchange login failure with new phone seems to have corrupted my exchange account


I had a Galaxy S3 (4.1.2) working fine on exchange server 2003.

I broke the screen and replaced it with a Droid Razr Maxx HD (also 4.1.2) . I set-up the corporate exchange email account following normal procedures. It accepted everything using manual set-up, started syncing the exchange account (up to April 5th) then it started coming up with a incorrect username or password error. I verified the password and tried again until my exchange account locked me out.

I called IT, they verified username, password and server settings. unlocked my account, and I attempted to login in again 3 times unsuccessfully until it again locked me out. Rinse and repeat. If I factory reset the phone and unlock my exchange account, it will again initially work and start to sync, then go back to the same error.

They created a new user account for me as a test. Everything works fine on the new account. They are reluctant to delete my current exchange account and move me to another one because I work for a local government agency and all my activity is discoverable under the freedom of information act and this would greatly complicate things.

I tried to go back to my broken SIII, an now it will not log on to my exchange account either. Same username and password error as Razr Maxx HD.

I also grabbed a spare phone, a Samsung stratosphere (2.3.6) and my HP Touchpad runnning CM9 Tenderloin and both log on to my exchange account just fine.

Verizon says everything is provisioned correctly, that it is an exchange problem. My IT says nothing has changed at the exchange server and that my current account and the test account have the same settings.
HELP!



.

forum.xda-developers.com

[General] Best talk to text app


Suggestions for a text app that lets you speak your text instead of typing please. Thanks!!! Rita

Sent from my SAMSUNG-SGH-I317 using Android Central Forums



.

forum.xda-developers.com

[General] Best phone for listening to music?


My razr is terrible for listening to music, i end up using my ipod instead. Are there any phones that would be as good in sound quality as an ipod?

Sent from my DROID RAZR using Android Central Forums



.

forum.xda-developers.com

[General] Huawei G330d dual sim, how do I install UK google version ?


Hi, i'm new to this so please bear with me....

I've just purchased a Huawei G330d dual sim phone via a website buysku in china, I specified when ordering that I wanted the uk version of android market/apps/googler play...etc to which they agreed they would do...but guess what...? It's got the chineese version of android !

How can I uninstall it and re-install with the uk version ?

many thanks in advance for your help

p.s, phone is unlocked, language changed to english (usa) and has version 4.04 installed



.

forum.xda-developers.com

Monday, April 15, 2013

[General] Damaged Screen help.


First off do you have insurance on your phone. This could be in handy if the Device Company says it is user fault. Typically this rarely happens with an undamaged screen but it is insurance for a reason.

I would call HTC device services and speak to a representative. Explain to them that this has occurred and there was no physical damage to the phone and it started happening. With this issue it could be a hardware malfunction and they could send you a replacement phone. I would not recommend fixing the phone yourself until you call technical services. Sometimes companies have issues with their phones and do not advertise it because it is not a majority.

I have had an issue similar with a samsung phone and received a free replacement and upgrade. (this is going 5 years back). Your provider can only guarantee a warranty for an X amount of days where the physical device is under a 1 year warranty.

All else fails and you have the insurance, I would pay the deductible for a replacement when you file a claim.



.

forum.xda-developers.com

[android help] Referencing jar file of google play service in map v2 project

android - Referencing jar file of google play service in map v2 project - Stack Overflow



















I'm trying to reference the jar file of google-play-service-lib but each time i reference it from the properties window, it gives me a red cross beside the lib. I tried uninstalling the google play service from the SDK service and re-installing it again.. also it didn't work up.


okay now i've changed the path of importing to the same drive where i keep my projects and thx god it worked... but now the maps open with a white blank page.


and what was written in the logcat : Unable to load google maps


can u please help me solving this issue :)





























import “google-play-services_lib”.
Select File-->Import
Select Android-->Existing Android Code into Workspace
Browse and select \sdk\extras\google\google_play_services\libproject
Select “google-play-services_lib” and finish.

for detailed steps have a look at to my blog: http://umut.tekguc.info/en/content/google-android-map-v2-step-step




















default






.

stackoverflow.comm

[android help] Jelly Bean Screen Capture on Device With No Volume Buttons


I am aware of the screen capture feature in Jelly Bean. This requires pressing the power and volume hardware buttons to do a capture. However, the hardware on which I am working does not have any hardware volume buttons. Is there any non-programmatic alternative to performing a screen capture?



.

stackoverflow.comm

[android help] Best practice to store keys associated with a class


I want to share what I did for preferences storage, I use android's build in feature called SharedPreferences. For easy access, I create a wrapper around SharedPreferences called UserModel that have codes like this:



package tv.gsgw.android.garusuta.model;

import id.flwi.util.ActivityUtil;
import tv.gsgw.android.garusuta.constant.DataConstant;
import android.content.Context;

public class UserModel implements DataConstant {
Context _context;

private String authKey = "";
private String email = "";
private String password = "";
private String birthdate = "";
private String prefacture = "";
private String bloodType = "";
private String idealBodyType = "";
private String duration = "";
private String stability = "";
private String skin = "";
private String relationship = "";
private String height = "";
private String weight = "";
private boolean registerDataChange = false;

public UserModel(Context context){
this._context = context;
loadFromPreferences();
}

public void loadFromPreferences(){
setAuthKey(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_AUTHKEY, ""));
setEmail(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_EMAIL, ""));
setPassword(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_PASSWORD, ""));
setBirthdate(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_BIRTHDATE, ""));
setPrefacture(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_PREFACTURE, ""));
setBloodType(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_BLOODTYPE, ""));
setIdealBodyType(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_BODYTYPE, ""));
setPeriod(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_DURATIONPERIOD, ""));
setStability(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_STABILITY, ""));
setSkin(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_SKINTYPE, ""));
setRelationship(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_RELATIONSHIP, ""));
setHeight(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_HEIGHT, ""));
setWeight(ActivityUtil.getSharedPreferenceString(_context, USER_DATA_FIELD_NAME_WEIGHT, ""));
setRegisterDataChange(ActivityUtil.getSharedPreferenceBoolean(_context, USER_DATA_FIELD_REGISTER_DATACHANGE, false));
}

public void saveIntoPreferences(){
saveIntoPreferences(true);
}
public void saveIntoPreferences(boolean datachanged){
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_AUTHKEY, getAuthKey());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_EMAIL, getEmail());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_PASSWORD, getPassword());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_BIRTHDATE, getBirthdate());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_PREFACTURE, getPrefacture());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_BLOODTYPE, getBloodType());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_BODYTYPE, getIdealBodyType());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_DURATIONPERIOD, getPeriod());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_STABILITY, getStability());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_SKINTYPE, getSkin());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_RELATIONSHIP, getRelationship());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_HEIGHT, getHeight());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_NAME_WEIGHT, getWeight());
ActivityUtil.setSharedPreference(_context, USER_DATA_FIELD_REGISTER_DATACHANGE, datachanged);
}

public String getAuthKey() {
return authKey;
}

public void setAuthKey(String authKey) {
this.authKey = authKey;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getBirthdate() {
return birthdate;
}

public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}

public String getPrefacture() {
return prefacture;
}

public void setPrefacture(String prefacture) {
this.prefacture = prefacture;
}

public String getBloodType() {
return bloodType;
}

public void setBloodType(String bloodType) {
this.bloodType = bloodType;
}

public String getIdealBodyType() {
return idealBodyType;
}

public void setIdealBodyType(String idealBodyType) {
this.idealBodyType = idealBodyType;
}

public String getPeriod() {
return duration;
}

public void setPeriod(String period) {
this.duration = period;
}

public String getSkin() {
return skin;
}

public void setSkin(String skin) {
this.skin = skin;
}

public String getRelationship() {
return relationship;
}

public void setRelationship(String relationship) {
this.relationship = relationship;
}

public String getHeight() {
return height;
}

public void setHeight(String height) {
this.height = height;
}

public String getWeight() {
return weight;
}

public void setWeight(String weight) {
this.weight = weight;
}

public boolean isRegisterDataChange() {
return registerDataChange;
}

public void setRegisterDataChange(boolean registerDataChange) {
this.registerDataChange = registerDataChange;
}

public String getStability() {
return stability;
}

public void setStability(String stability) {
this.stability = stability;
}

public void setRegistrationChanged(boolean dataChange) {
this.registerDataChange = dataChange;
}

public String toString(){
String str = "";

str += "authKey: " + authKey + "\n";
str += "email: " + email + "\n";
str += "password: " + password + "\n";
str += "birthdate: " + birthdate + "\n";
str += "prefacture: " + prefacture + "\n";
str += "bloodType: " + bloodType + "\n";
str += "idealBodyType: " + idealBodyType + "\n";
str += "duration: " + duration + "\n";
str += "stability: " + stability + "\n";
str += "skin: " + skin + "\n";
str += "relationship: " + relationship + "\n";
str += "height: " + height + "\n";
str += "weight: " + weight + "\n";
str += "registerDataChange: " + (registerDataChange ? "true" : "false") + "\n";

return str;
}

}


DataConstant in code above is just a class that contain constant variable like this:



public static final String USER_DATA_FIELD_NAME_AUTHKEY = "new_AuthKey";
public static final String USER_DATA_FIELD_NAME_EMAIL = "new_Email";
public static final String USER_DATA_FIELD_NAME_PASSWORD = "new_Password";
public static final String USER_DATA_FIELD_NAME_BIRTHDATE = "new_Birthday";
public static final String USER_DATA_FIELD_NAME_PREFACTURE = "new_Prefacture";
public static final String USER_DATA_FIELD_NAME_BLOODTYPE = "new_BloodType";
public static final String USER_DATA_FIELD_NAME_BODYTYPE = "new_IdealBodyType";
public static final String USER_DATA_FIELD_NAME_DURATIONPERIOD = "new_Duration";
public static final String USER_DATA_FIELD_NAME_STABILITY = "new_Stability";
public static final String USER_DATA_FIELD_NAME_SKINTYPE = "new_Skin";
public static final String USER_DATA_FIELD_NAME_RELATIONSHIP = "new_Relationship";
public static final String USER_DATA_FIELD_NAME_HEIGHT = "new_Height";
public static final String USER_DATA_FIELD_NAME_WEIGHT = "new_Weight";
public static final String USER_DATA_FIELD_NAME_PHY_1 = "new_phy1";
public static final String USER_DATA_FIELD_NAME_PHY_2 = "new_phy2";


This use an utility class that also create to help working with SharedPreferences easier:



package id.flwi.util;

/**
* @author Arief Bayu Purwanto
*/
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Calendar;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

public class ActivityUtil {
public static final String PREFS_NAME = "____MyPrefsFile";

public static void debugExtra(Bundle extras){
if( extras != null) {
Log.i("Log", "printing all extras information");
java.util.Set keys = extras.keySet();
java.util.Iterator keyIterator = keys.iterator();
int index = 0;
while(keyIterator.hasNext()) {
Log.i("log", " extras #" + (++index) + ": " + keyIterator.next());
}
} else {
Log.i("Log", "empty extras");
}
}

public static boolean getSharedPreferenceBoolean(Context c, String preference){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
return settings.getBoolean(preference, false);
}
public static boolean getSharedPreferenceBoolean(Context c, String preference, boolean defaultValue){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
return settings.getBoolean(preference, defaultValue);
}
public static String getSharedPreferenceString(Context c, String preference){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
return settings.getString(preference, "");
}
public static String getSharedPreferenceString(Context c, String preference, String defaultValue){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
return settings.getString(preference, defaultValue);
}
public static int getSharedPreferenceInt(Context c, String preference, int defaultValue){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
return settings.getInt(preference, defaultValue);
}

public static long getSharedPreferenceLong(Context c, String preference, long defaultValue){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
return settings.getLong(preference, defaultValue);
}

public static void setSharedPreference(Context c, String preference, boolean prefValue){

SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(preference, prefValue);
editor.commit();
}

public static void setSharedPreference(Context c, String preference, Long prefValue){

SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putLong(preference, prefValue);
editor.commit();
}

public static void setSharedPreference(Context c, String preference, int prefValue){

SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt(preference, prefValue);
editor.commit();
}
public static void setSharedPreference(Context c, String preference, String prefValue){
SharedPreferences settings = c.getSharedPreferences(ActivityUtil.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(preference, prefValue);
editor.commit();
}

}


Using it is pretty simple:



  1. To load the data, you just have to call:



    UserModel sharedData = new UserModel(getApplicationContext());



  2. To change or retrieve data just call it's associated field getter/setter:



    sharedData.getPassword();
    sharedData.setPassword("new password");



  3. Finally, if you change field(s), just don't forget to call saveIntoPreferences:



    sharedData.saveIntoPreferences();


Hope this help to solve your problem.



.

stackoverflow.comm

[android help] Nested set activity for result android

Nested set activity for result android - Stack Overflow



















I have 3 activities. A,B and C. A calls B, B calls C, and the result of C should be received in A. Can you please suggest how to go about it?? I m killing B using finish() after it calls C. So, the result of C should go directly to A Activityonresult. Is it possible??. Please give your suggestions!


























Don't kill B, in A start activity B using startActivityForResult and in B start activity C using startActivityForResult then in B onActivityResult



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);

setResult(RESULT_OK, intent);
finish();
}


where intent is the intent sent back from C. Now A will receive this intent in A onActivityResult.


























What if you call C from A? Something like: A calls B; instead of calling C from B, finish it and make A call C.


Unless the result of C affects B. In such case you have no choice but handling the result of C in B, and set the result of A from there if needed.




















default






.

stackoverflow.comm

[android help] Something wrong happened when updating app online


Recently I just meet a problem when I want to update my app online. My codes are shown below:



try {
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED)) {
String sdpath = Environment.getExternalStorageDirectory()+ "/";
mSavePath = sdpath + "download/";
URL url = new URL(downUrl);
conn = (HttpURLConnection) url.openConnection();
conn.connect();
// get the size of target file
int length = conn.getContentLength();
is = conn.getInputStream();

File file = new File(mSavePath);
if (!file.exists()) {
file.mkdir();
}
File apkFile = new File(mSavePath, FILE_NAME);
fos = new FileOutputStream(apkFile);
int count = 0;
byte buf[] = new byte[1024];
do {
int numread = is.read(buf);
count += numread;
progress = (int) (((float) count / length) * 100);
mHandler.sendEmptyMessage(DOWNLOAD);
if (numread <= 0) {
fos.flush();
isDownloadFinished = true;
break;
}
fos.write(buf, 0, numread);
fos.flush();
} while (true); // just for test
} else {
System.out.println("no external SDcard");
}
} catch (Exception e) {
mHandler.sendEmptyMessage(DOWNLOADFAIL);
e.printStackTrace();
} finally {
try {
conn.disconnect();
fos.close();
is.close();
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
mDownloadDialog.dismiss();
if (isDownloadFinished == true) {
mHandler.sendEmptyMessage(DOWNLOAD_FINISH);
}
}


And in handleMessage(), there is a function: installApk(). Of course it's in case DOWNLOAD_FINISH.



private void installApk() {
File apkfile = new File(mSavePath, FILE_NAME);
if (!apkfile.exists()) {
return;
}
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(mSavePath + FILE_NAME)),
"application/vnd.android.package-archive");
FileDownloadActivity.this.startActivity(i);
}


OK, this is my main code. Simply what I want to do is to replace(or we can say "update") current app with new version which just been downloaded. And next step is to click "Yes" when the dialog which alert us with something like "you're goning to replace the app" shown. Then a progress shown,which means the new verion app is been installing. BUT, now the problem appear: the install surface just exit without any result, alert or infotmation! This is a very simple test app, without anything such as:database, package sign and so on. So anybody met this problem? I need your help. Oh, by the way, forgive my damn poor English... :)



.

stackoverflow.comm

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...