Wednesday, April 3, 2013

[Q] Galaxy grand tethering issue




Default[Q] Galaxy grand tethering issue




My galaxy grand successfully tethers but fails to give the internet connect ie When i tether it and connect it to my laptop or pc I get connected but have no internet.This feature worked before but not now!And I have tried all solution that I'm aware of and cant get it to work.Plz help


.

forums.androidcentral.com

why string is not compare using double equal sign [closed]

java - why string is not compare using double equal sign - Stack Overflow



















Why string is not comparable using ==. Why we must use isEqualToString for compare two strings.


Thanks in advance



















It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.















becouse with == you compare the object references and with equalsIgnoreCase() the values of the String objects.























The way the == operator works in java is as follows:


  • Compare values for primitive types, such as doubles, ints, etc.

  • Compare the location in memory for objects (in other words, it has to be the same object it can't just look the same at a given moment). Since String is an object and not a primitive type, the latter rule applies.

Here is the source:


http://stevenrbrandt.com/cios/index.php/strings.xml


Hope it helps.












Not the answer you're looking for? Browse other questions tagged or ask your own question.






lang-java






.

forum.xda-developers.com

(Req) 4.2 Camera




Default(Req) 4.2 Camera




Was wondering if anyone can upload the 4.2 jellybean camera and also if it could it be modded to have the power button picture option and mute. I decided to go back to stock koodo because I was having too many issues with other roms but I really liked the 4.2 camera.

Sent from my SGH-T989D using xda premium



.

forums.androidcentral.com

[Q] Unreliable Data Connection/Modem Question




Default[Q] Unreliable Data Connection/Modem Question




I started flashing custom roms to my current phone 2 years ago, but now it started to bother me about my data connection. When I was in stock, I had a very reliable data connection (4G I believe). However now, it does not even connect to 4G. Is flashing a custom ROM (originally GB, now JB) affecting my data connection? This bothers me a lot as whenever I'm not in wifi range the internet becomes very unreliable, especially when using it with GPS.

Another potential related topic is modems. Is that really related to my problem? How do I know if I have an updated version?



.

forums.androidcentral.com

Tutorial :- Changing App Icons



DefaultTutorial :- Changing App Icons




Hi Friends,

This is a little Tutorial about changing app icons permanently. There was a lot of applications available in Playstore like “ icon changer free” etc etc to change the app icons. But the problem is that u cant use that changed apps in ur app drawer. U can only use that in ur home screen as a shortcut.

So I just decided to put a little tutorial to do that easily. I know everybody will know this already. But it will help for someone I am sure….

Credit goes to my friend dewanshu93 for teaching me this by personally

Credit Why So Serious? For the Icons

(And Sorry For My Bad English)

Tools Needed:-

(a) One PC
(b) 7 zip
(c) Some good icons

STEPS:-

1) Get some cool icons from here http://forum.xda-developers.com/show....php?t=2207136 and save it ur PC. Give him big thanks for the work.

Edit:- If u need some cool Galaxy S4 icons means go here: - http://forum.xda-developers.com/show....php?t=2216289 Please give thanks for his work..

2) Put the apps u want to change the icons to a Folder in ur PC. For example SemcAlbum, Phonebook, Browser etc

3) Here I am taking the Phonebook app for Example..

4) Right Click the Phonebook apk -> Open With -> 7zip File Manager. Then U will get a box contained some files like the attached Image 1

5) Then double click on the res folder and u get another box like attached Image 2

6) Find the folder named “ drawable-xhdpi “ and open it. U will get This Image 3

7) And most important thing is u need to find the original icon and its name of the phonebook.apk or whatever apk u take …

8) For that an easy way is create a new folder in ur PC’s Desktop and select all the images from the box ( Image 3 ) then drag it to the that new folder in the desktop.

9)Then open that folder then search for original the apk icon. Look in to Image 4

10) In my case the name of the Phonebook.apk’s icon is “ic_launcher_contacts “. So just note down the icon name and then open the folder that contains the icons that u downloaded. Image 5

11) And choose which icon u need and select it. Then rename it to the exact name of the original apk icon. ( For example ic_launcher_contacts )

12) After that just drag that renamed icon to res/drawable-xhdpi. It will ask for over right. Press Ok or Yes. Do the same process for res/drawable-hdpi and drawable-mdpi. Means drag the icon to these folders too. That’s it. Copy the apk to ur phone and move it to the System/app with correct permission…

Check the lastly Attached Two images for ur refference .

U can do it with almost all the apks. But I cant guarantee that it will work with all apks. Some System apks did not worked for me…

And also u can take icos from other apks too..

And this is my first work in XDA. Any mistake is there means I am sorry…

Thanks....


.

forums.androidcentral.com

Mount Windows Phone 7 device in linux for datarecovery




DefaultMount Windows Phone 7 device in linux for datarecovery




Hi,

Im trying to mount my Lumia 800 in Ubuntu, the device is automatically accessible but I would like to run some recovery software against it? but for example testdisk does not see the device... could I recover deleted photos somehow from the device?

Thanks


.

forums.androidcentral.com

in-app billing doesn't work: "IAB Helper is not set up"


I tried to include in-app billing in my app and for the purpose of testing, based the whole procedure on the "TrivialDrive" example for version 3 of in-app billing (and implementing the unmodified versions of the IAB files as supplied in the "util" subdirectory of the demo), but it doesn't work for me - on LogCat, just before the app terminates with an error, it gives the message "In-app billing error: Illegal state for operation (launchPurchaseFlow): IAB Helper is not set up." (right after the startRegistered() function has been fired and given me the LOG message "Register button clicked; launching purchase flow for upgrade.")...


Any idea what goes wrong here?


Here are the relevant parts of my code:



package com.mytest;

(..)
import com.mytest.iab.IabHelper; // the originals from the demo example, unmodified
import com.mytest.iab.IabResult;
import com.mytest.iab.Inventory;
import com.mytest.iab.Purchase;

public class Result3 extends Activity implements OnClickListener {

private static final String TAG = "BillingService";

private Context mContext;

boolean mIsRegistered = false;

// this has already been set up for my app at the publisher's console
static final String IS_REGISTERED = "myregistered";

static final int RC_REQUEST = 10001;

// The helper object
IabHelper mHelper;

/** Call when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.result3);
mContext = this;

String base64EncodedPublicKey = "[my public key]"; // (from publisher's console for my app)

// Create the helper, passing it our context and the public key to verify signatures with
Log.d(TAG, "Creating IAB helper.");
mHelper = new IabHelper(this, base64EncodedPublicKey);

// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(true);

// Start setup. This is asynchronous and the specified listener
// will be called once setup completes.
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");

if (!result.isSuccess()) {
complain("Problem setting up in-app billing: " + result);
return;
}

// Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
});

// Set the onClick listeners
findViewById(R.id.btnPurchase).setOnClickListener(this);
}

// Listener that's called when we finish querying the items we own
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
if (result.isFailure()) {
complain("Failed to query inventory: " + result);
return;
}

Log.d(TAG, "Query inventory was successful.");

// Do we have the premium upgrade?
mIsRegistered = inventory.hasPurchase(IS_REGISTERED);
Log.d(TAG, "User is " + (mIsRegistered ? "REGISTERED" : "NOT REGISTERED"));

setWaitScreen(false);
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};

// User clicked the "Register" button.
private void startRegistered() {
Log.d(TAG, "Register button clicked; launching purchase flow for upgrade.");
setWaitScreen(true);
mHelper.launchPurchaseFlow(this, IS_REGISTERED, RC_REQUEST, mPurchaseFinishedListener);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
// not handled, so handle it ourselves (here's where you'd
// perform any handling of activity results not related to in-app billing..
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}

// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
// Oh noes!
complain("Error purchasing: " + result);
setWaitScreen(false);
return;
}

Log.d(TAG, "Purchase successful.");

if (purchase.getSku().equals(IS_REGISTERED)) {
Log.d(TAG, "User has registered..");
alert("Thank you.");
mIsRegistered = true;
setWaitScreen(false);
}
}
};

// We're being destroyed. It's important to dispose of the helper here!
@Override
public void onDestroy() {
// very important:
Log.d(TAG, "Destroying helper.");
if (mHelper != null) mHelper.dispose();
mHelper = null;
}

void complain(String message) {
Log.e(TAG, "**** Register Error: " + message);
alert("Error: " + message);
}

void setWaitScreen(boolean set) {
// just a dummy for now
}

void alert(String message) {
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setMessage(message);
bld.setNeutralButton("OK", null);
Log.d(TAG, "Showing alert dialog: " + message);
bld.create().show();
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnPurchase:
startRegistered();
break;
default:
break;
}
}


}


Here more lines from Logcat:



12-20 01:06:36.701: D/dalvikvm(299): GC_FOR_MALLOC freed 4262 objects / 308592 bytes in 84ms
12-20 01:06:36.701: D/webviewglue(299): nativeDestroy view: 0x2ea718
12-20 01:06:36.771: W/webcore(299): Can't get the viewWidth after the first layout
12-20 01:07:07.111: W/webcore(299): Can't get the viewWidth after the first layout
12-20 01:07:18.510: D/webviewglue(299): nativeDestroy view: 0x2dd458
12-20 01:07:18.510: D/dalvikvm(299): GC_FOR_MALLOC freed 6042 objects / 544504 bytes in 50ms
12-20 01:07:18.530: D/webviewglue(299): nativeDestroy view: 0x2ea8d0
12-20 01:07:18.660: D/BillingService(299): Creating IAB helper.
12-20 01:07:18.660: D/BillingService(299): Starting setup.
12-20 01:07:18.660: D/IabHelper(299): Starting in-app billing setup.
12-20 01:07:19.621: W/webcore(299): Can't get the viewWidth after the first layout
12-20 01:07:20.160: W/webcore(299): Can't get the viewWidth after the first layout
12-20 01:07:32.481: D/webviewglue(299): nativeDestroy view: 0x3f88e8
12-20 01:07:32.491: D/dalvikvm(299): GC_FOR_MALLOC freed 5798 objects / 513640 bytes in 50ms
12-20 01:07:32.511: D/BillingService(299): Register button clicked; launching purchase flow for upgrade.
12-20 01:07:32.511: E/IabHelper(299): In-app billing error: Illegal state for operation (launchPurchaseFlow): IAB helper is not set up.
12-20 01:07:32.521: D/AndroidRuntime(299): Shutting down VM
12-20 01:07:32.521: W/dalvikvm(299): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-20 01:07:32.541: E/AndroidRuntime(299): FATAL EXCEPTION: main
12-20 01:07:32.541: E/AndroidRuntime(299): java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: launchPurchaseFlow
12-20 01:07:32.541: E/AndroidRuntime(299): at com.test_ed.iab.IabHelper.checkSetupDone(IabHelper.java:673)
12-20 01:07:32.541: E/AndroidRuntime(299): at com.test_ed.iab.IabHelper.launchPurchaseFlow(IabHelper.java:315)
12-20 01:07:32.541: E/AndroidRuntime(299): at com.test_ed.iab.IabHelper.launchPurchaseFlow(IabHelper.java:294)
12-20 01:07:32.541: E/AndroidRuntime(299): at com.test_ed.Result3.startRegistered(Result3.java:157)
12-20 01:07:32.541: E/AndroidRuntime(299): at com.test_ed.Result3.onClick(Result3.java:248)
12-20 01:07:32.541: E/AndroidRuntime(299): at android.view.View.performClick(View.java:2408)
12-20 01:07:32.541: E/AndroidRuntime(299): at android.view.View$PerformClick.run(View.java:8816)
12-20 01:07:32.541: E/AndroidRuntime(299): at android.os.Handler.handleCallback(Handler.java:587)
12-20 01:07:32.541: E/AndroidRuntime(299): at android.os.Handler.dispatchMessage(Handler.java:92)
12-20 01:07:32.541: E/AndroidRuntime(299): at android.os.Looper.loop(Looper.java:123)
12-20 01:07:32.541: E/AndroidRuntime(299): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 01:07:32.541: E/AndroidRuntime(299): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 01:07:32.541: E/AndroidRuntime(299): at java.lang.reflect.Method.invoke(Method.java:521)
12-20 01:07:32.541: E/AndroidRuntime(299): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 01:07:32.541: E/AndroidRuntime(299): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 01:07:32.541: E/AndroidRuntime(299): at dalvik.system.NativeStart.main(Native Method)


.

forums.androidcentral.com

Adding Functionality to both Android's Activity (parent class) and FragmentActivity (child class) in best coding style (minimal duplication)


In Android Library, FragmentActivity extends Activity. I would like to add a few methods, and override some methods, of the original Activity.



import android.app.Activity

public class Activiti extends Activity {
public void myNewMethod() { ... }
}


Because of the original hierarchy, FragmentActivity extends Activity, myNewMethod() should also be present in my library's FragmentActiviti



import android.support.v4.app.FragmentActivity;

public abstract class FragmentActiviti extends FragmentActivity {
public void myNewMethod() { ... }
}


But this will lead to a duplication of code, which i do not want this happens. Is there a way to avoid this duplication?



Edit: Usage scenario


Activiti.java



public abstract class Activiti extends Activity {
private int current_orientation = Configuration.ORIENTATION_UNDEFINED; // ORIENTATION_UNDEFINED = 0

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
current_orientation = this.getResources().getConfiguration().orientation;
}
protected boolean isDevicePortrait() { return current_orientation == Configuration.ORIENTATION_PORTRAIT; }
}


FragmentActiviti.java



public abstract class FragmentActiviti extends FragmentActivity {
/* This onCreate() can be omitted. Just putting here explicitly. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

protected void someUtilsForFragments() { /* not used yet */ }
}


E_fragtest_06.java



public class E_fragtest_06 extends FragmentActiviti {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.printf(isDevicePortrait()); // this NOT WORK for now
}
}



Edit 2: Try using Util class


i think using the Decorator Class would be the most nicest way to solve this problem (no duplication of code). But the Decorator Pattern is just a bit hard (or impossible) to apply on Android Activity scenario.


i try implementing @hazzik's approach, but i still experience some problems.


ActivityUtil.java



public abstract class ActivityUtil {
private int current_orientation = Configuration.ORIENTATION_UNDEFINED; // ORIENTATION_UNDEFINED = 0

public void onCreate(Activity activity, Bundle savedInstanceState) {
activity.onCreate(savedInstanceState);
current_orientation = activity.getResources().getConfiguration().orientation;
}
public boolean isDevicePortrait() { return current_orientation == Configuration.ORIENTATION_PORTRAIT; }
}


Activiti.java



public class Activiti extends Activity {
private ActivityUtil activityUtil;

@Override
public void onCreate(Bundle savedInstanceState) {
activityUtil.onCreate(this, savedInstanceState);
}
protected boolean isDevicePortrait() { return activityUtil.isDevicePortrait(); }
}


FragmentActiviti.java



public abstract class FragmentActiviti extends FragmentActivity {
private ActivityUtil activityUtil;

@Override
public void onCreate(Bundle savedInstanceState) {
activityUtil.onCreate(this, savedInstanceState);
}
protected boolean isDevicePortrait() { return activityUtil.isDevicePortrait(); }
}


In ActivityUtil.onCreate(), activity.onCreate(savedInstanceState); is causing this compile error:



The method onCreate(Bundle) from the type Activity is not visible.



If i change Activity to Activiti:



public abstract class ActivityUtil {
public void onCreate(Activiti activity, Bundle savedInstanceState) { ... }
...
}


It will lead to another compile error in FragmentActiviti.onCreate()'s activityUtil.onCreate():



The method onCreate(Activiti, Bundle) in the type ActivityUtil is not applicable for the arguments (FragmentActiviti, Bundle)



i understand why those errors occur. But i just don't know how to avoid them.



To thanks all the guys who have been contributing to this question, especially @flup for guiding me about the Decorator Pattern, @hazzik and @donramos for your extensive efforts, i m here posting



If you are also developing Android applications, i hope my codes could help you guys in some ways :-)


ActivityCore.java



package xxx.android;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;

public final class ActivityCore {
public interface ActivityCallbackInterface {
public void onCreateCallback(Bundle savedInstanceState);
public void onBeforeSaveInstanceState(Bundle outState);
public void onSaveInstanceStateCallback(Bundle outState);
}

private final Activity activity;
/**
* This current_orientation variable should be once set, never changed during the object life-cycle.
* But Activity.getResources() is not yet ready upon the object constructs.
* That's why THIS CLASS is wholly responsible to maintain THIS VARIABLE UNCHANGED.
*/
private int current_orientation = Configuration.ORIENTATION_UNDEFINED; // ORIENTATION_UNDEFINED = 0

public ActivityCore(Activity activity) { this.activity = activity; }

public void onCreate(Bundle savedInstanceState) {
((ActivityCallbackInterface) activity).onCreateCallback(savedInstanceState);
current_orientation = activity.getResources().getConfiguration().orientation;
}

public void onSaveInstanceState(Bundle outState) {
/**
* THIS is the best ever place i have found, to unload unwanted Fragments,
* thus prevent re-creating of un-needed Fragments in the next state of Activity.
* (state e.g. Portrait-to-Landscape, or Landscape-to-Portrait)
*
* The KEY is to do it BEFORE super.onSaveInstanceState()
* (my guess for this reason is, in super.onSaveInstanceState(),
* it saves the layout hierarchy, thus saved the Fragments into the Bundle also.
* Thus restored.
* Note that Fragments NOT IN LAYOUT, having ONLY TAGS, are also restored.)
*/
((ActivityCallbackInterface) activity).onBeforeSaveInstanceState(outState);
((ActivityCallbackInterface) activity).onSaveInstanceStateCallback(outState);
}

public int getCurrentOrientation() { return current_orientation; }

public boolean isDevicePortrait() { return current_orientation == Configuration.ORIENTATION_PORTRAIT; }
public boolean isDeviceLandscape() { return current_orientation == Configuration.ORIENTATION_LANDSCAPE; }
public boolean isNewDevicePortrait() { return activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }
public boolean isNewDeviceLandscape() { return activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }
public boolean isPortrait2Landscape() { return isDevicePortrait() && isNewDeviceLandscape(); }
public boolean isLandscape2Portrait() { return isDeviceLandscape() && isNewDevicePortrait(); }

public String describeCurrentOrientation() { return describeOrientation(current_orientation); }
public String getCurrentOrientationTag() { return getOrientationTag(current_orientation); }
public String describeNewOrientation() { return describeOrientation(activity.getResources().getConfiguration().orientation); }
public String getNewOrientationTag() { return getOrientationTag(activity.getResources().getConfiguration().orientation); }
private String describeOrientation(final int orientation) {
switch (orientation) {
case Configuration.ORIENTATION_UNDEFINED: return "ORIENTATION_UNDEFINED"; // 0
case Configuration.ORIENTATION_PORTRAIT: return "ORIENTATION_PORTRAIT"; // 1
case Configuration.ORIENTATION_LANDSCAPE: return "ORIENTATION_LANDSCAPE"; // 2
case Configuration.ORIENTATION_SQUARE: return "ORIENTATION_SQUARE"; // 3
default: return null;
}
}
@SuppressLint("DefaultLocale")
private String getOrientationTag(final int orientation) {
return String.format("[%d:%s]", orientation, describeOrientation(orientation).substring(12, 16).toLowerCase());
}
}


Activity.java



package xxx.android.app;

import xxx.android.ActivityCore;
import xxx.android.ActivityCore.ActivityCallbackInterface;
import android.os.Bundle;

public abstract class Activity extends android.app.Activity implements ActivityCallbackInterface {
private final ActivityCore activityCore;

public Activity() { super(); activityCore = new ActivityCore(this); }

@Override
protected void onCreate(Bundle savedInstanceState) { activityCore.onCreate(savedInstanceState); }
@Override public void onCreateCallback(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }

@Override
public void onBeforeSaveInstanceState(Bundle outState) {} // Optionally: let child class override
@Override
protected void onSaveInstanceState(Bundle outState) { activityCore.onSaveInstanceState(outState); }
@Override public void onSaveInstanceStateCallback(Bundle outState) { super.onSaveInstanceState(outState); }

public final int getCurrentOrientation() { return activityCore.getCurrentOrientation(); }

public final boolean isDevicePortrait() { return activityCore.isDevicePortrait(); }
public final boolean isDeviceLandscape() { return activityCore.isDeviceLandscape(); }
public final boolean isNewDevicePortrait() { return activityCore.isNewDevicePortrait(); }
public final boolean isNewDeviceLandscape() { return activityCore.isNewDeviceLandscape(); }
public final boolean isPortrait2Landscape() { return activityCore.isPortrait2Landscape(); }
public final boolean isLandscape2Portrait() { return activityCore.isLandscape2Portrait(); }

public final String describeCurrentOrientation() { return activityCore.describeCurrentOrientation(); }
public final String getCurrentOrientationTag() { return activityCore.getCurrentOrientationTag(); }
public final String describeNewOrientation() { return activityCore.describeNewOrientation(); }
public final String getNewOrientationTag() { return activityCore.getNewOrientationTag(); }
}


FragmentActivity.java



package xxx.android.support.v4.app;

import xxx.android.ActivityCore;
import xxx.android.ActivityCore.ActivityCallbackInterface;
import android.os.Bundle;

public abstract class FragmentActivity extends android.support.v4.app.FragmentActivity implements ActivityCallbackInterface {
private final ActivityCore activityCore;

public FragmentActivity() { super(); activityCore = new ActivityCore(this); }

@Override
protected void onCreate(Bundle savedInstanceState) { activityCore.onCreate(savedInstanceState); }
@Override public void onCreateCallback(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }

@Override
public void onBeforeSaveInstanceState(Bundle outState) {} // Optionally: let child class override
@Override
protected void onSaveInstanceState(Bundle outState) { activityCore.onSaveInstanceState(outState); }
@Override public void onSaveInstanceStateCallback(Bundle outState) { super.onSaveInstanceState(outState); }

public final int getCurrentOrientation() { return activityCore.getCurrentOrientation(); }

public final boolean isDevicePortrait() { return activityCore.isDevicePortrait(); }
public final boolean isDeviceLandscape() { return activityCore.isDeviceLandscape(); }
public final boolean isNewDevicePortrait() { return activityCore.isNewDevicePortrait(); }
public final boolean isNewDeviceLandscape() { return activityCore.isNewDeviceLandscape(); }
public final boolean isPortrait2Landscape() { return activityCore.isPortrait2Landscape(); }
public final boolean isLandscape2Portrait() { return activityCore.isLandscape2Portrait(); }

public final String describeCurrentOrientation() { return activityCore.describeCurrentOrientation(); }
public final String getCurrentOrientationTag() { return activityCore.getCurrentOrientationTag(); }
public final String describeNewOrientation() { return activityCore.describeNewOrientation(); }
public final String getNewOrientationTag() { return activityCore.getNewOrientationTag(); }
}


Lastly, i really have to thanks you guys are being so so so helpful and keep updating the solving progress with me! You all are the key persons who make stackoverflow a perfect site for programmers. Should you spot any problems in my codes, or any rooms for improvements, please do not hesitate to help me again :-)



It is because onBeforeSaveInstanceState() is implemented upon usage, all the three classes need to keep abstract. This leads to a duplication of the member variable current_orientation. If current_orientation could be put into class ActivityBase, or grouping it into somewhere else, it would be a lot nicer!


stupid me. i have fixed it :-)



.

forums.androidcentral.com

Unit testing Android application logic


Looking to write some tests for my application, I stumbled upon the Android testing pages. After a fairly long read, it quickly became apparent that the only thing that I could possibly get out of it is information about how to test the UI/Activities. What I really want is the way to test my logic with simply ant test, preferably without even involving the device. I should mention at this stage that I am not using Eclipse and it's quite saddening that 99% of the Java resources on Android assume people do so.


In any case, trying to get anything at all running, I played along with the tutorial as much as I could. It asks that a tests directory is made on the same level as src. Sure, even if every other of their pages implies that the test-project is a completely separate entity. While in the top level project directory, I ran android create test-project -m /path/to/my/project/ -n MyProjectTest -p tests. It's worth mentioning that they are very inconsistent with saying how they want things to be set up as seen on this question. Visiting the directory, I spot the default testing file. Here's where the issues begin.


To my understanding, testing is done as follows: build application, install; go to tests, build tests, install; run tests from the tests directory using ant test or start them directly using adb shell am instrument. This worked fine. I however have no desire to test the activity but just the logic (which doesn't access any Views/Activities).


Changing the default test to extend AndroidTestClass seemed to have work for a while. The tests were being ran but there were caveats: cleaning tests with ant clean also cleaned the project directory (../tests) so it took forever to build tests in a clean environment (which is necessary because ant debug seems terrible at detecting changes) but it worked and I was happy.


Few more tests later, I get java.lang.VerifyError on my only test class. Googling and Stacking around, it boiled down to either something wrong with external libs or something wrong with my class path. I'm not using any external .jars so it's probably my path.


In any case, here is my question: what is The Proper Way™ to unit test logic in Android applications with JUnit? I can't find any resources at all concerning this: all resources are either for testing the UI parts or for unit testing ordinary applications.


How can I unit test my logic only? This shouldn't even require a device to run on given that I don't need to use any parts of Android. Where do I place the tests? What do I need to change so that running ant test in my project directory will then run those?



.

forums.androidcentral.com

Not showing Main Activity after Splash screen


I under stand the thousand of people saying "don't use a splash," I get it, but the app is not that big, I just want to know what I am doing wrong I think it is something with my Manifest but after my splash shows and when its supposed to go to main page, I get error "Sorry! The Application Grifball (process com.grifball.info) has stopped unexpectedly. Please try again.


Here is my Manifest.




package="com.grifball.info"
android:versionCode="1"
android:versionName="1.0" >

android:minSdkVersion="8"
android:targetSdkVersion="8" />

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >








android:name="MainActivity"
android:label="@string/app_name" >












Here is my Splash's Java



package com.grifball.info;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Splash extends Activity{

@Override
protected void onCreate(Bundle startup) {
// TODO Auto-generated method stub
super.onCreate(startup);
setContentView(R.layout.splash);

Thread timer = new Thread(){

public void run(){

try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openMainActivity = new Intent("com.grifball.info.MAINACTIVITY");
startActivity(openMainActivity);
}
}

};
timer.start();
}

}


Here is the XML




android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/splashbg">





.

forums.androidcentral.com

How to add an index in json data?


I have following data structure:



Class UserModel {
Long pkid;
String name;
public UserModel() {
this.pkid = new Long(1001);
this.name = "ABC";
}
}


Now I have converted this into json:



UserModel usrObj = new UserModel();
Gson gson = new Gson();
String json = gson.toJson(userObj);


So my json string is now like:



{ "pkid": 1001,
"name": "ABC" }


But I need to create the json as



{"com.vlee.ejb.UserModel": [
{ "pkid": 1001,
"name": "ABC" } ] }


I am not sure how I can add the key "com.vlee.ejb.UserModel"



.

forums.androidcentral.com

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...