views:

196

answers:

2

Hello oh great wizards of all things android. I really need your help. Mostly because my little brain just doesn't know were to start. I am trying to pull data from the internet to make a widget for the home screen. I have the layout built:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/Layout"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="@drawable/widget_bg_normal"
 android:clipChildren="false"

 >

 <TextView
     android:id="@+id/text_view"
            android:layout_width="100px"
            android:layout_height="wrap_content"
            android:paddingTop="18px"
            android:layout_centerHorizontal="true"
            android:textSize="8px"
            android:text="158x154 Image downloaded from the internet goes here.  Needs to be updated every evening at midnight or unless the button below is pressed.  Now if I could only figure out exactly how to do this, life would be good."

 />

 <Button
  android:id="@+id/new_button"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="Get New"
  android:layout_below="@+id/scroll_image"
  android:layout_centerHorizontal="true"
  android:padding="0px"
  android:textSize="10px"
  android:height="8px"
  android:includeFontPadding="false"

  />

</RelativeLayout>

Got the provider xml bulit:

<?xml version="1.0" encoding="utf-8"?>

<appwidget-provider
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:minWidth="150dip"
    android:minHeight="150dip"
 android:updatePeriodMillis="10000"
 android:initialLayout="@layout/widget"
/>

The Manifest works great.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.dge.myandroid"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".myactivty"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

       <!-- Widget -->
       <receiver
        android:name=".mywidget"
        android:label="@string/app_name"
        >
         <intent-filter>
          <action
     android:name="android.appwidget.action.APPWIDGET_UPDATE"
    />
   </intent-filter>

   <meta-data
    android:name="android.appwidget.widgetprovider"
    android:resource="@xml/widgetprovider"
   />
  </receiver>
  <!-- Widget End -->

    </application>

    <uses-permission android:name="android.permission.INTERNET" />


    <uses-sdk android:minSdkVersion="7" />

</manifest> 

The data it is calling looks something like this when it is called. It basically goes to a website that uses php to random the image:

<html><body bgcolor="#000000">center>    
<a href="http://www.website.com" target="_blank">
<img border="0" src="http://www.webiste.com//0.gif"&gt;&lt;/a&gt;
<img src="http://www.webiste.com" style="border:none;" />
</center></body></html>

But here is were I am stuck. I just don't know where to start at all. The java is so far beyond my little head that I don't know what to do.

package com.dge.myandroid;

import android.appwidget.AppWidgetProvider;

public class mywidget extends AppWidgetProvider {



}

The wiki example just confused me more. I just don't know where to begin. Please help.

+1  A: 

If data is hosted on a WebSite, you can use HttpClient on Android to make the proper request and get your data.

These SO questions might help.

Pablo Santa Cruz
How much would you charge to write the code for me? (Yes, I am that frustrated.)
cdg
A: 

There is code at anddev doing pretty much what you want. The first post is about xml but if you read through there's more, including fetching and parsing HTML.

Jon