Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Peter Hawke

@Peter Hawke
About
Posts
5
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Web Request in Android failing
    P Peter Hawke

    Thanks a lot! Here is the code I used:

    new Thread(new Runnable() {
    public void run() {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet("http://www.google.com/pxi");
    ResponseHandler resHandler = new BasicResponseHandler();
    String page = "";
    try {
    page = httpClient.execute(httpGet, resHandler);
    } catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    final String p = page;
    Log.e("response" , page);
    //return "Successful!";
    test.post(new Runnable() {
    public void run() {
    test.setText(p);
    }
    });
    }
    }).start();

    Also this page I found helpful: http://developer.android.com/guide/components/processes-and-threads.html[^]

    Java android com json announcement

  • Web Request in Android failing
    P Peter Hawke

    Okay so I have an app widget and I am trying to make a web request and It just keeps failing. Here is the code:

    public class IDEAAllotmentTrackerActivity extends AppWidgetProvider {
    /** Called when the activity is first created. */
    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
    int[] appWidgetIds) {
    // To prevent any ANR timeouts, we perform the update in a service
    context.startService(new Intent(context, UpdateService.class));
    }
    public static class UpdateService extends Service {
    @Override
    public void onStart(Intent intent, int startId) {
    // Build the widget update for today
    RemoteViews updateViews = null;
    try {
    updateViews = buildUpdate(this);
    } catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();

    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		// Build an update that holds the updated widget contents
            
    		
            // Push update for this widget to the home screen
            ComponentName thisWidget = new ComponentName(this, IDEAAllotmentTrackerActivity.class);
            AppWidgetManager manager = AppWidgetManager.getInstance(this);
            manager.updateAppWidget(thisWidget, updateViews);
        }
    
        /\*\*
         \* Build a widget update to show the current Wiktionary
         \* "Word of the day." Will block until the online API returns.
         \* @throws IOException 
         \* @throws ClientProtocolException 
         \*/
        public RemoteViews buildUpdate(Context context) throws ClientProtocolException, IOException{
        	HttpClient httpclient = new DefaultHttpClient();
            HttpResponse response = httpclient.execute(new HttpGet("http://www.google.com"));
            StatusLine statusLine = response.getStatusLine();
            String pageContent = "";
            if(statusLine.getStatusCode() == HttpStatus.SC\_OK){
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                response.getEntity().writeTo(out);
                out.close();
                pageContent = out.toString();
                //..more logic
            } else{
                //Closes the connection.
                response.getEntity().getContent().close();
                throw new IOException(statusLine.getReasonPhrase());
            }
    
    
            RemoteViews update
    
    Java android com json announcement

  • Programming Question
    P Peter Hawke

    Actually I am 14 and I wrote one to start defraggler and CCleaner when my computer starts up. But I didn't know that the startup folder only starts exe files instead of BAT files. So know I just run it so I don't have to start both of them manually

    The Lounge question xml

  • i need your help
    P Peter Hawke

    Great 3D physics engine that will handle drawing and everything. Great and wonderful software. Go here. :-D :thumbsup:

    Game Development question game-dev help

  • game
    P Peter Hawke

    Well in C# it is very possible to make a nice game in 3D, using the BEPU Physics engine http://channel9.msdn.com/coding4fun/blog/Get-a-free-and-open-source-physics-library-in-BEPUphysics-for-Windows-XBox-and-WP7[^]. Haven't tested the DLL with vb thought.

    I am at home in VB but will adapt to anything!

    Game Development csharp game-dev
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups