Thursday, November 28, 2013

How to have a getStringExtra message before onCreate method? [android help]


How to have a getStringExtra message before onCreate method?


java - How to have a getStringExtra message before onCreate method? - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
















I have two activities which in the first one I make a message and by putExtra I move it to next activity. But as you know to get the message in the secind activity I need to have getStringExtra in onCreate method. In the other hand I really need to have that message before onCreate starts. So how can I have that.



public class Result extends Activity {
String url; // <<< I need the message to put it here

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_result);

Intent intent = getIntent();
String mainURL = intent.getStringExtra(SingleSearchPage.EXTRA_MESSAGE); // Here is the message

url = mainURL; //Tried to change the value of URL but did not work

new GetJSONTask().execute(url);

}
class GetJSONTask extends AsyncTask {


protected JSONObject doInBackground(String... urls) {
// Creating new JSON Parser
JSONParser jParser = new JSONParser();

// Getting JSON from URL
JSONObject json = jParser.getJSONFromUrl(url);

return json;
}


Any idea to have the value of intent message before the onCreate?



















lang-java






Read more

stackoverflow.comm



Android SDK Eclipse Issue with Running in Emulator [android help]


Android SDK Eclipse Issue with Running in Emulator



I am building the layout for an android app. I am not getting any errors when running the app; however, I am getting an error right away when the app launches in the emulator. I am assuming it is a layout rendering fault. Where can I view the error, because no errors are shown in Eclipse.



Read more

stackoverflow.comm



Using get() and put() to access pixel values in OpenCV for JAVA [android help]


Using get() and put() to access pixel values in OpenCV for JAVA



I am a beginner in using OpenCV for JAVA. I want to access individual pixel values of an image matrix. Since, JAVA jar for OpenCV doesn't offer nice functions like C++, I ran into some trouble. After lot of searching, I found out two different methods to do that though they are not explained properly (not even in documentation). We can do that either using get() and put() functions or by converting the mat data into a primitive java type such as arrays. I tried both but getting different output results! Please help explaining what am I doing wrong. Am I using them wrong or some other silly problem. I am still a newbie so please forgive if its a stupid question. :)


CASE 1: Using get() function



Mat A = Highgui.imread(image_addr); \\"image_addr" is the address of the image
Mat C = A.clone();
Size sizeA = A.size();
for (int i = 0; i < sizeA.height; i++)
for (int j = 0; j < sizeA.width; j++) {
double[] data = A.get(i, j);
data[0] = data[0] / 2;
data[1] = data[1] / 2;
data[2] = data[2] / 2;
C.put(i, j, data);
}


CASE 2: Using Array



Mat A = Highgui.imread(image_addr); \\"image_addr" is the address of the image
Mat C = A.clone();
int size = (int) (A.total() * A.channels());
byte[] temp = new byte[size];
A.get(0, 0, temp);
for (int i = 0; i < size; i++)
temp[i] = (byte) (temp[i] / 2);
C.put(0, 0, temp);


Now according to my understanding they both should do the same thing. They both access the individual pixel values (all 3 channels) and making it half. I am getting no error after running. But, the output image I am getting is different in these two cases. Can someone please explain what is the issue? May be I don't understand exactly how get() function works? Is it because of the byte() casting? Please help.


Thanks!



Read more

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