Register    Login    Forum    Search    FAQ

Board index » Programming » Android Application Development




 Page 1 of 1 [ 5 posts ] 



Author Message
 Post subject: Struggling to create something as an activity ?
 Post Posted: Mon Jan 21, 2013 6:04 pm 
Offline
Novice User
Novice User

Joined: Sun Dec 30, 2012 10:06 am
Posts: 16
Languages: HTML5, CSS, JS, PHP and learning others !
Text editor: Notepad ++
Hello everyone,

New to Android and cannot create as an Activity. My activity isn't been found the LogCat said.

Trying to send this as an Activity but figure it out, when I hover over it shows as void com.test.myappname.postData()

Have been reading through Android documentation but completely stumped by this.

Thanks in advance !

java code:
 
 
public class test extends Activity{
       
 
        public void postData() {
            // Create a new HttpClient and Post Header
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
 
            try {
                // Add your data
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("id", "name"));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
 
                httpclient.execute(httppost);
               
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
            } catch (IOException e) {
                // TODO Auto-generated catch block
            }
        }
       
}


Top 
 Post subject: Re: Struggling to create something as an activity ?
 Post Posted: Wed Jan 23, 2013 9:47 am 
Offline
Hero of the Forum
Hero of the Forum

Joined: Mon Oct 11, 2010 1:24 pm
Posts: 525
Location: The Netherlands
Languages: Java, C++, JavaScript, Wicket, Prolog, Haskell, (English, Dutch, German, Spanish)
Text editor: Programmers Notepad
Could you give us the exact error message (copy it from your logcat window).

About your problem. Did you check if your activity is defined in your manifest.xml?

Also don't you need some sort of entry point in your activity (see code below)?
code:
//this method will be called when you start your activity.
@Override
public void onCreate(Bundle savedInstanceState) {
     postData();
}


Kind regards,
Bram

_________________
You will always find something in the last place you look.


Top 
 Post subject: Re: Struggling to create something as an activity ?
 Post Posted: Thu Jan 31, 2013 9:17 am 
Offline
n00b
n00b
User avatar

Joined: Tue Jan 29, 2013 11:42 pm
Posts: 4
Languages: Java, C#, SQL, VB.NET
Text editor: For what? I have an IDE
I am gonna go with Bram. There is no entry point into your class extending activity. You need to override onCreate at the very least. There are 200 videos on the subject around here...


Top 
 Post subject: Re: Struggling to create something as an activity ?
 Post Posted: Thu Feb 07, 2013 1:27 am 
Offline
Forum Veteran
Forum Veteran

Joined: Tue Sep 04, 2012 1:05 am
Posts: 134
Location: NewYork
Languages: English
Text editor: Notepad
Please share the error message.If it is possible for you.

_________________
John Farrell
Technical Consultant
website: http://www.rapidsofttechnologies.com/


Top 
 Post subject: Re: Struggling to create something as an activity ?
 Post Posted: Mon Feb 18, 2013 11:22 am 
Offline
Rookie
Rookie

Joined: Fri Feb 15, 2013 8:11 am
Posts: 11
First create OnCreate override method. Then check if your activity is listed in Manifest xml file. And then use setContentView(R.layout.yourxmlfile);


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 5 posts ] 




Board index » Programming » Android Application Development


Who is online

Users browsing this forum: Bing [Bot] and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: