I am now stopping a force on my Android emulator.
After finishing this app, I just want to insert a custom field instead of testing, but for now I just want to show it via HTTP activity.
Any help would be great!
Main activity:
The public class extends the main activity activity {public's last fixed string EXTRA_MESSAGE = "com.example.main. Message"; / * @ SuppressLint ("Parser Enter") @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super.New (Saved Instantstate); SetContentView (R.layout.activity_main); } * / @ Override public boolean on cret option menu (menu menu) {getMenuInflater (). Flood (R. menu activism_menen, menu); Back true; } Private Button Search BTN; @ Override Protected Zero (Bundle Saved Instance) {Super. Contents (Saved Instances); SetContentView (R.layout.activity_main); SearchBtn = (button) findViewById (R.id.button1); SearchBtn.setOnClickListener (New View.OnClickListener () {public void onClick (see v) {intent = intent (new), zero.class; startActivity;}}); }} http:
public class http activity {public http () {httpMethod (); } Public Zero httpMethod () {HttpClient httpclient = New DefaultHttpClient (); HttpPost httppost = New HttpPost ("http://api.site.com/api/"); Try {// Add Your Data List & lt; NameValuePair & gt; NameValuePairs = New ArrayList & lt; NameValuePair & gt; (2); ; // Execute HTTP Post Request HTTP Response Response = httpclient.execute (httppost); String test = "hello"; TextView myTextView = (TextView) Find ViewById (R.id.myTextView); MyTextView.setText (test); } Capture (Client Protocol E) {// To-Auto-Generated Cal Block} Catch (IoException E) {// Todo Auto-Generated Catch Block}}} Manifest:
& lt; Use-SDK Android: minSdkVersion = "8" Android: targetSdkVersion = "15" /> Android: Android: Android: Android: Android: Theme = "@ Style / Aaptim" & gt; & Lt; Activity Android: Name = "main activity" Android: label = "@ string / title_activity_man" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.MAIN" /> & Lt; Category android: name = "android.intent.category.LAUNCHER" /> & Lt; / Intent-Filter & gt; & Lt; / Activity & gt; & Lt; Activity Android: name = "com.example.main.DisplayMessageActivity" /> & Lt; Activity Android: name = "com.example.main.http" /> & Lt; / Application & gt; & Lt; Use-permission Android: name = "android.permission.INTERNET" & gt; & Lt; / Usage-permission & gt; & Lt; / Reveal & gt;
There are a lot of problems with the code:
1) < Code> intended intent = new intent (empty, http.class);
Use main parameters instead of tap main activity. onCreate (or) onResume 2) To create an activity for
/ Code> At least on the methods of life cycle activity, please spend some time reading the document and creating some example programs and posting on SO instead of typing some type. Going through all your questions is something like the Society did your app for you.
Comments
Post a Comment