Sunday, April 21, 2013

[android help] Android Default Browser not loading on a particular URL


Im doing an automation using monkeyrunner. The script that I'm doing needs to load URL in the Android Default Browser, however when I tried to use the URL shown below, the Browser is not loading, and it does not open the browser at all.


http://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCEQFjAA&url=http://ark.com.ge/&ei=IDeoUIPUI-ik0AWa1oCIDg&usg=AFQjCNE1H_KILEGlt8o_ewzUszZUJfMV9A&sig2=Ygg8NBvIiOWFfiziSKFJKA


The question is, what's with this URL, and why is the Browser not working? the length? the combination of characters?


By the way, this URL is working in the desktop.


Thanks



.

stackoverflow.comm

[android help] PhoneGap / Sencha Touch: WebView render issue on hide SoftKeyboard


A few months back, I spent a ton of time trying to figure this issue out. Tried out a bunch of stuff, sifted through Google/StackOverflow.


Ultimately I wasn't able to do exactly what I was looking for; it doesn't look like we have enough (easy) control over the keyboard from Sencha Touch/PhoneGap for a lot of things (on top of the keyboard position, we also have basically 0 control over what the "return/go/ok" button actually does, which varies between Android versions, especially when it's a number field.) However:


Mitigation 1: windowSoftInputMode="stateUnspecified|adjustResize" will cause the keyboard to cover the input, but once the user starts typing, the screen will adjust to show the input right above the keyboard, and things will revert as desired upon input blur. This is at least the case for my Samsung Galaxy S2 (2.6), Samsung Galaxy S3 (4.2), and Kyocera Rise (4.0).


Mitigation 2: One solution I implemented was, on input focus, changing the position of the inputs to guarantee that they'll be above the keyboard. Upon input blur, the input will change to its original location. This is not ideal because you'll often see the inputs move to the new location before the keyboard covers it up, so it looks pretty janky.


Mitigation 3: For number fields, I used a modified version of https://market.sencha.com/extensions/numpad that created a virtual keyboard and set it to "showBy()" the required input. That ensured that the keyboard never covered up the input and the app didn't have to deal with any re-positioning of the screen (screenshot below).


Problem with mitigation 3: The problem here is that it is only for number fields, and I was not able to find any standard keyboard plugins for Sencha Touch (my app is number focused so that limitation was acceptable.) That said, I'm sure you could spend a few days using the numpad plugin as a core to build a virtual keyboard that could work in a similar way.


Sorry for the lack of a perfect solution. I hope this is helpful!


enter image description here



.

stackoverflow.comm

[android help] Android Listview Item not drawn after setVisibility(View.VISIBLE) is called


I have a list view each row in the list view has height of 450dp for an example so in most cases, the listview will render at MOST 3 items at the time.


when list view is initially loaded, each row is just an image with a button that says "show details" (all contained in a relative layout) when user clicks on the button, it hide the current relative layout that has an image and a button by calling setVisibility(View.GONE), and make another view (LinearLayout) shown by calling setVisibility(View.VISIBLE)


Remember BOTH relative layout and Linear Layout reside in the same xml that was inflated in Adapter.getView(), i am just toggle one of the other in terms of the visibility.


the issue is that, after calling setVisibility(View.VISIBLE) is called on the linear layout, it doesn't show. It did successfully hide the relative layout, but the linearly layout did not appear.


It only appears AFTER a new item in the list view needs to be rendered by scrolling the list view up and down.


how can i force the relative layout to get shown? by force redrawing? i tried that by calling invalidate, it did not work.


i also tried requestLayout, but again, no use.


i also tried notifyDataSetChanged(), it did not work, and i don't think i should call it anyway, because nothing in the data in the adapter has changed, i am simple hiding and showing a new view.


please help



.

stackoverflow.comm

[android help] What should I use Android AccountManager for?

What should I use Android AccountManager for? - 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've seen AccountManager in the Android SDK and that it is used for storing account information. Thus, I cannot find any general discussion of what it is intended for. Does anyone know of any helpful discussions of what the intention behind AccountManager is and what it buys you? Any opinions of what type of Accounts this is suitable for? Would this be where you'd put your user's account information for a general web service?





























This question is a bit old, but I think it is still of good interest.


AccountManager, SyncAdapter and ContentProvidergo together. You cannot use an AccountManager without a SyncAdapter. You cannot use a SyncAdapter without an AccountManager. You cannot have a SyncAdapterwithout a ContentProvider.


With AccountManager / SyncAdapter / ContentProvider:


  • AccountManager gives users a central point (Settings > Accounts) to define their credentials

  • Android decides when synchronization can be done via SyncAdapter. This can be good (no sync when network is down)

  • ContentProvider is the only way to share data across applications

  • ContentProvider schedules the database access in a background thread, preventing ANR errors while not requiring you to explicitly handle threading.

  • ContentProvider ties into ContentResolver's observer: this means it is easy to notify views when content is changed

Bottom line: the framework AccountManager / SyncAdapter / ContentProvider helps if you want to synchronize data from a web resource. Mockup/Dumb implementations are required if you don't really need one of these pieces. Also


  • If you only want to store data, you should consider a simpler mechanism for data storage

  • If you only want to get only resource, you can consider a Service / Alarm

  • only available from API >= 7

























From http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/:



The first piece of the puzzle is called an Account Authenticator, which defines how the user’s account will appear in the “Accounts & Sync” settings. Implementing an Account Authenticator requires 3 pieces: a service that returns a subclass of AbstractAccountAuthenticator from the onBind method, an activity to prompt the user to enter their credentials, and an xml file describing how your account should look when displayed to the user. You’ll also need to add the android.permission.AUTHENTICATE_ACCOUNTS permission to your AndroidManifest.xml.























The AccountManager class is integrated with your phone accounts. So if you follow all the guides and get it working correctly you'll see your accounts under the menu "Settings->accounts and synch". From there you can customize them or even delete them. Furthermore the accountManager has a cache of the authentication tickets for your accounts. This can be used also if you don't plan to synchronize your account (as far as i know).


If you don't want your accounts to appear under that menu you shouldn't use the AccountManager and store the accounts data elsewhere (maybe in the shared preferences) http://developer.android.com/guide/topics/data/data-storage.html






















I will disagree with some of whats been written as I have implemented AccountManager without having to use SynchAdapter or a content provider.


The password is saved encrypted SHA1-256 and account auth tokens are generated which are used to access a remote resource.


Whatever implementation strategy you use, ensure you follow the tutorial and setup the xml preferences correctly.




















default







.

stackoverflow.comm

[android help] "FragmentTabHost cannot be resolved to a type"

android - "FragmentTabHost cannot be resolved to a type" - 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.

















Just now am starting to build apps on android.I added ADT plugin form this site https://dl-ssl.google.com/android/eclipse/ Then I did File->new->other->Android->Android Sample Project->Support13Demos[Android Support Library] think that this some demo so that i could learn something but its says "FragmentTabHost cannot be resolved to a type" in one of the files I had 2 more errors which i resolved by downloading the 2 jars android-support-v4.jar and android-support-v13.jar.but this error doesnt seem go i think these to need a jar i am finding it very difficult to get that.Any suggestions on this would be helpful. As am trying Android for the time please do tell if i have assumed/trying something wrong thanks
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default







.

stackoverflow.comm

[android help] How to building an android application for specific device?

build - How to building an android application for specific device? - 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 developed an android app and i want to give it to testers for test, so i want to make several specific build for each tester, runnable on specific tester device not any devices.


the reason is when i give a build of my app to a tester, the app just be runnable on his device not others, so can not be published and run on any other devices!
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default







.

stackoverflow.comm

[android help] BroadcastReceiver in a Service : Design Issues


My App needs to listen to a broadcast event (HEADSET events) and act accordingly. I discovered that HEADSET events cannot be used via a minifest receiver as the flag FLAG_RECEIVER_REGISTERED_ONLY is enabled for this event. So, you can only register to this event dynamically inside your program. As my App would not be active during the events, I needed a service to handle this event , I register in onCreate and unregister in onDestroy. So far, so good. I implemented the service and started testing it, I discovered that the service can be killed by the system in case of a resource crunch and the system will automatically restart the service. However, the surprising thing is that the delay between kill and restart, which is completely random and could be HUGE. Sometimes, it was in seconds and other times it was in hours. So, you can never be sure that your service is running when the broadcast event happens !


I have browsed stackoverflow on that there were various suggestions. Have a dummy thread that does nothing to increase "importance" of the service, use service with startForeground - which causes a Notification. All these look like workarounds and not foolproof.


Is there any way of solving this in a foolproof manner ? What can be alternate solutions for handling "REGISTERED_ONLY" broadcast events ?


Thanks.



.

stackoverflow.comm

[android help] android camera preview callback is drawing overlay view very slowly


FaceDetector is built to detect faces in arbitrary bitmaps. Since you are wanting to detect faces in an active camera preview perhaps you might try using the Camera.FaceDetectionListener implementation of face detection as described here:


http://developer.android.com/guide/topics/media/camera.html#face-detection


It is likely that this method of detecting faces is optimized for working in concert with an active camera preview frame.


As well, try opening the stock Android camera app on your device and watch as it detects faces. Does it detect them at the same speed as the face detection in your app? If it's faster, then there's likely something you can do to make your app faster. If not, then your app is likely already as fast as it will get on that device.


For reference, face detection in the stock app on my Nexus 4 averages probably about 0.2s (5 per second) and on my Nexus 10 is a bit slower, probably at about 0.33s (3 per second.)



.

stackoverflow.comm

[android help] SQL/Ruby On Rails Project


For a school project, we are to create an android application that incorporates a server some sensors and uses a data source, so I have decided to make a Geo-caching clone, but for my local university.


The university suggests using Axis2 but I have decided to use Ruby on Rails for the server part. I have never learnt Ruby on Rails so I have been reading tutorials and guides online, so I am still a newbie!


Currently I have a User Model setup, with an association with Items. The user Model has a fields of name and email. While the items have a location, name and a keyword.


What I want the server to be able to do, is when a user creates a new item and uploads its coordinates, a keyword is randomly generated, and returned back to the user, is there anyway this can be done?



.

stackoverflow.comm

[android help] play embedded mp4 video in html5 using phonegap in android


I am trying to play embedded mp4 video in my html5 application running on android. I went though few ideas.


  1. Plugin URL: https://github.com/macdonst/VideoPlayer
    Result: Video player working in Android environment BUT the video is playing in a separate app

  2. Plugin URL: https://github.com/zencoder/video-js
    Result: Video player not working in Android BUT working perfectly in a web browser.

BTW, I am using phonegap 2.6.0. Any leads to my solution?



.

stackoverflow.comm

[android help] JSONParser cannot be resolved to a type

java - JSONParser cannot be resolved to a type - 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.

















Trying to follow this tutorial: Tutorial


Trying to use JSONParser like so:



// Creating JSON Parser object
JSONParser jParser = new JSONParser();


But Eclipse gives me the JSONParser cannot be resolved to a type.


What to do?





























The JSONParser class is lower down on the tutorial it looks like this...



public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

// constructor
public JSONParser() {

}

// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
List params) {

// Making HTTP request
try {

// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));

HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();

}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);

HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}

// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}

// return JSON String
return jObj;

}
}


I would consider looking at the jackson library tho http://jackson.codehaus.org/























When I use this JSON parser, I am asked for an input stream. I cannot do this: JSONParser jParser = new JSONParser();














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







lang-java







.

stackoverflow.comm

[android help] Android - How to work with nested ListViews


this is my first question on this site and I am also new to Android. I am creating an application using an online API. I am working with this API in XML and parsing the responses into ListViews. I have reached a point where I would like to select an item from a ListView in one activity and send that information to the next activity along with another ListView containing more information for the selected item. As an example, one activity has a list of bands. Clicking on the band name will bring up the band name and a list of tour dates on the next activity. According to my API, the band's ID number is needed to access the bands tour information I am trying to pass the ID number as a search parameter but cannot get this to work. I did manage to find a decent tutorial on androidhive.info but cannot seem to be able to apply these techniques. The doInBackground() method is where my app is hanging up.



ListView lv = getListView();

lv.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView parent, View view,
int position, long id) {
// getting values from selected ListItem
String displayName = ((TextView) view.findViewById(R.id.tvDisplayName)).getText().toString();
String onTourUntil = ((TextView) view.findViewById(R.id.tvOnTourUntil)).getText().toString();
String identification = ((TextView) view.findViewById(R.id.tvId)).getText().toString();

// Starting new intent
Intent in = new Intent(getApplicationContext(), SingleArtistActivity.class);
in.putExtra(KEY_DISPLAY_NAME, displayName);
in.putExtra(KEY_ID, identification);
in.putExtra(KEY_ON_TOUR_UNTIL, onTourUntil);

new AsyncDownload().execute(identification);

startActivity(in);
}
});


}



private class AsyncDownload extends AsyncTask {

ProgressDialog pDialog;

@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(ArtistsSearchActivity.this);
pDialog.setMessage("Please Wait...");

pDialog.setCancelable(false);
pDialog.show();
}

@Override
protected String doInBackground(String... params) {

Log.v(TAG, "query is" + params[0]);
String result = new ArtistCalendarHelper().getXml(params[0]);
return result;
}


My AsyncDownload class is called in my onClickListener. The class calls a helper that contains the URL and API key.



public class ArtistCalendarHelper {
private static final String TAG = "ArtistCalendarHelper";
private static final String SONGKICK_URL = "http://api.songkick.com/api/3.0/artists/";
private static final String API_KEY = "yIekMi1hQzcFheKc";

public String getXml(String identification) {

HttpClient httpclient = new DefaultHttpClient();

String getParameters = "";
try {
getParameters = URLEncoder.encode(identification, "UTF-8")
+ "/calendar.xml?apikey=" + URLEncoder.encode(API_KEY, "UTF-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

String url = SONGKICK_URL + getParameters;
// Prepare a request object
HttpGet httpget = new HttpGet(url);

// Execute the request
HttpResponse response;


These methods worked for obtaining the bands name in an initial search. How could this be changed to perform a search for tour information with an argument retrieved from a ListView? Is this different from getting a search query from an EditText field? I didn't think there would be much of a difference. I have tried to include the affected code. I am not sure how much code I should provide.



.

stackoverflow.comm

[android help] Android ListFragment Errors


This is my first time using ListFragments and I'm running into an error. So my question is why am I getting a red line on this line of code?



setListAdapter(new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1, model.getIncidents()));


it says The constructor ArrayAdapter(Activity, int, ArrayList) is undefined


Edit


I no longer get the above error for this fragment. I altered the code slightly and now it looks like this:



public class Incidents_Frag extends ListFragment {
View view;
public static Model model;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.incid, container, false);
model = new Model();
setListAdapter(new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1, model.getIncidents()));
return view;
}
}


However now I get a runtime error. The logcat is below



04-21 18:47:40.934: E/AndroidRuntime(806): FATAL EXCEPTION: main
04-21 18:47:40.934: E/AndroidRuntime(806): java.lang.RuntimeException: Content has view with id attribute 'android.R.id.list' that is not a ListView class
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.ListFragment.ensureList(ListFragment.java:402)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.ListFragment.onViewCreated(ListFragment.java:203)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:998)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.BackStackRecord.run(BackStackRecord.java:622)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1330)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:417)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.os.Handler.handleCallback(Handler.java:605)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.os.Handler.dispatchMessage(Handler.java:92)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.os.Looper.loop(Looper.java:137)
04-21 18:47:40.934: E/AndroidRuntime(806): at android.app.ActivityThread.main(ActivityThread.java:4340)
04-21 18:47:40.934: E/AndroidRuntime(806): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 18:47:40.934: E/AndroidRuntime(806): at java.lang.reflect.Method.invoke(Method.java:511)
04-21 18:47:40.934: E/AndroidRuntime(806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-21 18:47:40.934: E/AndroidRuntime(806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-21 18:47:40.934: E/AndroidRuntime(806): at dalvik.system.NativeStart.main(Native Method)


I cannot for the life of me figure out what they're talking about in the first line. I don't see any R.id files with the name list. I now believe I simply need to put a listview or a textview somewhere though. thanks for any help you can offer


Edit


Here is the new code for my fragment



public class Incidents_Frag extends ListFragment {
View view;
public static Model model;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.incid, container, false);
model = new Model();
setListAdapter(new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1, model.getIncidents()));
return view;
}

public class MyArrayAdapter extends ArrayAdapter {
ArrayList items;
Context context;
public MyArrayAdapter(Context context, int textViewResourceId,
ArrayList items) {
super(context, textViewResourceId, items);

this.context = context;
this.items = items;
}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View row = convertView;
ViewHolder holder = new ViewHolder();
Item item = items.get(position);

if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(R.layout.list_item, parent, false);
holder.userName = (TextView) row.findViewById(R.id.name);
row.setTag(holder);
}
else
{
holder = (ViewHolder) row.getTag();
}

holder.name.setText(item.getName());
return row;
}

public static class ViewHolder
{
TextView name;
}

public int getCount() {
return items.size();
}

}
}


I get red lines under Item item = items.get(position);


holder.userName = (TextView) row.findViewById(R.id.name);
"userName cannot be resolved"


holder.name.setText(item.getName());
"The method getName() is undefined for the type ClipData.Item"


public static class ViewHolder
"The member type ViewHolder cannot be declared static; static types can only be declared in static or top level types"


So if we can clear up these red lines, it may or may not work. If you would like me to continue down this path please advise on whether this code is in the right place, and what edits need to be done



.

stackoverflow.comm

[android help] Dynamically add button and row


I have a problem which I can't solve though surfing the internet all day long. Can the gurus here help me with my problem?


First, I have a welcome page, and an image button, after I clicked, it prompts me to user account creation page.


In this page, I wish to set a toolbar on top of my application with "Done" button on left, a phrase "Select Account" in middle and also "add button on right.


When I press "add" button on the toolbar, a new row with name and next image button will be added below. Maximum can be added up to 10 rows with specific row's height(u can see that it is cramped altogether which is hideous). And when I click the "next" button, the page will be brought to next page which prompts me to enter user details and can change the name of the row. After editing, I have a button which can be clicked, e.g. "OK" button to back to the page.


Lastly, I click on a row, it will be shaded as if like I selected it, and once I click "done" button, the row is selected prompts me back go to the welcome page.


Please help me~ http://share.pho.to/1vpPO (the link to view the photo)



.

stackoverflow.comm

[android help] Is it OK to use `scala.actors.Actor` object in an Android application?

Is it OK to use `scala.actors.Actor` object in an Android application? - 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 know that it works, just checked. I'm wondering about the system not being able to free memory or the application "hanging" in the background or such things.



import scala.actors.Actor
import android.util.Log

object Player extends Actor {

start

def act {
loop {
react {
case x => Log.v("actor", "received: " + x)
}
}
}

}


Actors are so much more graspable than concurrency using regular threads. I guess scala.actors is build upon JVM threads, so maybe it's as legal as using normal threads in your app?


























You shouldn't be using native scala actors, as they're deprecated. But you can run AKKA on Android. You can see this thread for more information and sample code: https://groups.google.com/forum/?fromgroups=#!topic/akka-user/1W41nAONv90




















lang-scala







.

stackoverflow.comm

[android help] Android Fragment pass information between fragements of same activity


I am not sure about other good options but you can definitely do the following.


say you have an activity named A and it has contained to fragment b and c. you need to send data from b to c.


as both b and c are child of activity A then can access the method of A. And A can also access the child fragments b and c. So to pass info from b to c create a method in A which will pass info to c and call it from b.


To be more specific you can see the doc.


So the fragment can access the Activity instance with getActivity() and easily call method



getActivity().passInfoToC(data);


Likewise, your activity can call methods in the fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById() or findFragmentByTag(). For example:



ExampleFragment fragment = (ExampleFragment)getFragmentManager().findFragmentById(R.id.example_fragment);
fragment.setData(data);


Then access a method to pass data.



.

stackoverflow.comm

[android help] Null Pointer exception when trying to layout inflate in service


I'm trying to layout Inflate in a service on onCreate with this code:



// ...
public void onCreate() {
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
call = new PhoneCall();

IntentFilter intentFilter = new IntentFilter(outgoingIntent);
registerReceiver(callReceiver, intentFilter);

final LayoutInflater myInflator = (LayoutInflater) ctext.getSystemService(Context.LAYOUT_INFLATER_SERVICE );

onPhoneStatelistener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {

// ...


Here is my log cat:



04-22 02:38:35.324: E/AndroidRuntime(28837): FATAL EXCEPTION: main
04-22 02:38:35.324: E/AndroidRuntime(28837): java.lang.RuntimeException: Unable to create service com.castello.AllMyCalls.CallService: java.lang.NullPointerException
04-22 02:38:35.324: E/AndroidRuntime(28837): at android.app.ActivityThread.handleCreateService(ActivityThread.java:1959)
04-22 02:38:35.324: E/AndroidRuntime(28837): at android.app.ActivityThread.access$2500(ActivityThread.java:117)
04-22 02:38:35.324: E/AndroidRuntime(28837): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:989)


I'm just getting a "Null Pointer" error. Any suggestions?



.

stackoverflow.comm

[android help] How to set the size of the display in WebView component?


On PC browser, the display is well. But open in Andriod webview, the display becomes very small. How to set the size of the display in WebView component?


Phone Display: http://i.imgur.com/6qi4lgj.jpg


PC Display: http://i.imgur.com/5wMdyqQ.jpg



.

stackoverflow.comm

[android help] Creating a socket to a remote HTTP Server using android emulator


I'm very new to android programming. I have a program that uses sockets to connect to a remote host, spoof an http request, and parse the results. For some reason, my socket cannot connect to the host. I have tested the program in a standalone environment and it connects and works fine. I went ahead and isolated the function I needed and included it in my activity class to call it that way. Ive also tried calling it staticly, as well as executing` an asynchronous object and calling it from there. The internet on my android emulator works from the browser, and i've added the






To my android manifest. The code below shows where I stand right now. What do do I need to do?



public class FlightNumResults extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
String value = intent.getStringExtra("input"); //if it's a string you stored.
//super.onCreate(savedInstanceState);
System.out.println("HULLO");
System.out.println(value);
setContentView(R.layout.loading);

Log.i("Excecution", "Complete");
Hashtable table = flightNumInfo(value);
if (table == null)
System.out.println("NULL");

TableLayout results = (TableLayout) findViewById(R.id.resultTable);

TableRow rowLabels = new TableRow(this);
TableRow rowResults = new TableRow(this);
rowLabels.setGravity(Gravity.CENTER);

TableRow.LayoutParams params = new TableRow.LayoutParams();
params.span = 4;

//Column 1
TextView destLabel = new TextView(this);
destLabel.setText("Destination");
destLabel.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView destResult = new TextView(this);
destResult.setText(table.get("destination"));
destResult.setGravity(Gravity.CENTER_HORIZONTAL);

rowLabels.addView(destLabel);
rowResults.addView(destResult);
//Column 2
TextView gateLabel = new TextView(this);
destLabel.setText("Gate");
destLabel.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView gateResult = new TextView(this);
destResult.setText(table.get("gate"));
destResult.setGravity(Gravity.CENTER_HORIZONTAL);

rowLabels.addView(gateLabel);
rowResults.addView(gateResult);
//Column 3
TextView scheduledLabel = new TextView(this);
destLabel.setText("Scheduled");
destLabel.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView scheduledResult = new TextView(this);
destResult.setText(table.get("scheduled"));
destResult.setGravity(Gravity.CENTER_HORIZONTAL);

rowLabels.addView(scheduledLabel);
rowResults.addView(scheduledResult);
//Column 4
TextView estimatedLabel = new TextView(this);
destLabel.setText("estimated");
destLabel.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView estimatedResult = new TextView(this);
destResult.setText(table.get("scheduled"));
destResult.setGravity(Gravity.CENTER_HORIZONTAL);

rowLabels.addView(estimatedLabel);
rowResults.addView(estimatedResult);

results.addView(rowLabels);
results.addView(rowResults);

setContentView(R.layout.activity_flightnum_results);





}
public Hashtable flightNumInfo(String flightNum) {

Hashtable table = new Hashtable();
System.out.println("Initializing socket");
try {
String request = "GET /flifo/servlet/DeltaFlifo?airline_code=DL&flight_number="
+ flightNum
+ "&flight_date="
+ DateCalc.getSlashDateAndTime()
+ "&request=main&DptText=ATL HTTP/1.1";

Socket conn = new Socket(InetAddress.getByName("www.delta.com"), 80);
System.out.println("initialized");
PrintWriter wr = new PrintWriter(conn.getOutputStream());

wr.println(request);
wr.println("Host: www.delta.com");
wr.println("Referer: http://www.delta.com/flifo/servlet/DeltaFlifo?airline_code=DL&request=main");
wr.println("Connection: close\n");
wr.flush();

Scanner in = new Scanner(conn.getInputStream());
String myResp = new String();
String ans = new String();

do {
ans = in.nextLine();
myResp += ans;
} while (ans.indexOf("
") < 0);

wr.close();
in.close();
// System.out.println(myResp);
Pattern p = Pattern
.compile(" \\s+Atlanta\\s+"
+ ""
+ "\\(ATL\\)
\\s+
 (.*?)"
+ "
  Gate ([A-Z0-9]{2,3})\\s+"
+ "\\s+\\s+ ([A-Za-z0-9:]{6,9})
\\s+ (.*?)\\s+"
+ "\\s+ ([a-z0-9*?:]{6,9}|[a-zA-Z\\s]{6,9})
\\s+ (.*?)\\s+"
+ " (.*?)\\(([A-Z]{3})\\)");


Matcher m = p.matcher(myResp);
if (m.find()) {
table.put("number", flightNum);
table.put("gate", m.group(2));
table.put("scheduled", m.group(3));
table.put("estimated", m.group(5));
table.put("destination", m.group(8));

return table;
}
} catch (Exception e) {
return null;
}
return null;
}

}


Here is what my code looks like using AsyncTask.



public class FlightNumResults extends Activity {

public String flightNum;
public Hashtable table;

@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
flightNum = intent.getStringExtra("input"); // if it's a string you
// stored.
super.onCreate(savedInstanceState);
System.out.println("HULLO");
// System.out.println(value);

setContentView(R.layout.loading);

Log.i("Excecution", "Complete");
FlightInfo fi = new FlightInfo();
fi.execute();
fi.flightNumInfo(flightNum);
// Hashtable table = fi.flightNumInfo(value);

// System.out.println(table.get("destination"));

// setContentView(R.layout.activity_flightnum_results);



}

public class FlightInfo extends AsyncTask {
public Socket conn;
public PrintWriter wr;
public DataInputStream dis;
public DataOutputStream dos;
@Override
protected Void doInBackground(Void... params) {
try {
conn = new Socket(InetAddress.getByName("www.delta.com"), 80);
}catch (Exception e){
Log.i("AsyncTank", "Can't create socket");
}
if (conn.isConnected()){
try {
dis = (DataInputStream)conn.getInputStream();
dos = (DataOutputStream)conn.getOutputStream();
Log.i("AsyncTank", "doInBackgoung: Socket created, Streams assigned");

} catch (IOException e) {
// TODO Auto-generated catch block
Log.i("AsyncTank", "doInBackgoung: Cannot assign Streams, Socket not connected");
e.printStackTrace();
}
} else {
Log.i("AsyncTank", "doInBackgoung: Cannot assign Streams, Socket is closed");
}
return null;

}
protected void onPostExecute(Boolean result) {
if (result) {
Log.i("AsyncTask", "onPostExecute: Completed with an Error.");

} else {
Log.i("AsyncTask", "onPostExecute: Completed.");

}
setContentView(R.layout.activity_flightnum_results);

}



public void flightNumInfo(String flightNum) {

table = new Hashtable();

String request = "GET /flifo/servlet/DeltaFlifo?airline_code=DL&flight_number="
+ flightNum
+ "&flight_date="
+ DateCalc.getSlashDateAndTime()
+ "&request=main&DptText=ATL HTTP/1.1";

//Socket conn = new Socket(InetAddress.getByName("www.delta.com"), 80);

wr = new PrintWriter(dos);

wr.println(request);
wr.println("Host: www.delta.com");
wr.println("Referer: http://www.delta.com/flifo/servlet/DeltaFlifo?airline_code=DL&request=main");
wr.println("Connection: close\n");
wr.flush();

Scanner in = new Scanner(dis);
String myResp = new String();
String ans = new String();

do {
ans = in.nextLine();
myResp += ans;
} while (ans.indexOf("
") < 0);

wr.close();
in.close();

// System.out.println(myResp);
Pattern p = Pattern
.compile(" \\s+Atlanta\\s+"
+ ""
+ "\\(ATL\\)
\\s+
 (.*?)"
+ "
  Gate ([A-Z0-9]{2,3})\\s+"
+ "\\s+\\s+ ([A-Za-z0-9:]{6,9})
\\s+ (.*?)\\s+"
+ "\\s+ ([a-z0-9*?:]{6,9}|[a-zA-Z\\s]{6,9})
\\s+ (.*?)\\s+"
+ " (.*?)\\(([A-Z]{3})\\)");


Matcher m = p.matcher(myResp);
if (m.find()) {
table.put("number", flightNum);
table.put("gate", m.group(2));
table.put("scheduled", m.group(3));
table.put("estimated", m.group(5));
table.put("destination", m.group(8));


}




}
}
}


.

stackoverflow.comm

[android help] view SQLite Databases in android listview?


I am sure there is an easy solution to this one but I figured I would check with all the folks here first.


I am working on a database creation and management application for android where the user creates and manages data along the line of what PHPMyAdmin does for regular computers.


I have the section where the user creates a database and can insert tables with the appropriate styled data into the system.


The next priority is selecting which DB to enter and modify its contents. Is there a way to display the available databases, along with its table contents, in the form of a list-view for the user to enter and edit the desired data??


I know that this is a rather dull question, but this is basically the last piece of the puzzle for me to fit into this app before it is operational in a raw format. If you need any further information, or any code to examine, I will be happy to provide.


Thanks again for everyone's assistance.



.

stackoverflow.comm

[General] Hardware repair now White Screen of Death


Okay I recently dropped my LG l38c breaking the screen and was able to find a parts phone and successfully made the repair, but on power-up I get the ol' W.S.o.D. I,ve verified the screen is good and there is no visible damage to the board or flex cables, I'm not in a financial place to get another phone for a week so please tell me someone has got a fix!



.

forum.xda-developers.com

[General] HTC One X+ Downloading Trojans


Hello Guys

My first post here but I really need help,when I first got my new phone it downloaded a random .apk through chrome and installed it. I hadn't given it permission to do anything so I completly reset the phone deleting all data. Then a few minutes ago I was on the Sun website ( a UK news website ) and it began to download a random .apk named 1234hws3.apk, again I never pressed anything or gave it permission so I managedto quickly reboot the phone hoping it would stop the Download. But I turned it back on and it said download complete and Avast Antivirus popped up saying it had detected a Trojan in the file and did I want to delete it. So obviously I let avast delete it and scanned it again and it came back all clear.

So the questions I have is why does it download these random .apk, is there anyway I can stop it, and can I assume my phone is clean? Does everyones phone do this every now and again?

By the way my phone is not rooted.



.

forum.xda-developers.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...