(savedinstancestate); Setcontentview (r.layout.main); button= (Button) Findviewbyid (R.id.button); ((gameapplication) getapplication ()). SetScore (+); Button.setonclicklistener (New View.onclicklistener () {public void OnClick (View v) {Intent intent=new Intent (); Intent.setclass (Demoactivity.this, Resultactivity.class); startactivity (intent);}});} }By setting a score in this activity, we can take it out of other activity:public class Resultactivity exten
Crawl the data on the Web page, then use the Android native code to display it, or borrow the Web data to display it in a custom view.This time use the Dom4j-1.6.1.jar library to get and parse the data. (dom4j Baidu Cloud: http://pan.baidu.com/s/1jHHa6O2)Here is the parse string using DOM4J (HTML format):Try { = doc
Sharedpreferences is a tool class for storing simple data in Android. Imagine that it is a small cookie that stores simple data types (boolean, int, float, long, and string) in the application's private directory by using key-value pairs (data/data/package name/shared_prefs/
= "Textnosuggestions" does not promptandroid:inputtype= "Texturi" urlAndroid:inputtype= "textemailaddress" email addressAndroid:inputtype= "textemailsubject" message subjectAndroid:inputtype= "Textshortmessage" SMSAndroid:inputtype= "Textlongmessage" long messageAndroid:inputtype= "Textpersonname" nameAndroid:inputtype= "Textpostaladdress" addressandroid:inputtype= "Textpassword" passwordAndroid:inputtype= "Textvisiblepassword" Visible passwordAndroid:inputtype= "Textwebedittext" as the text of
Android: the client obtains garbled data from the server.Send an HTTP request to the server. The received JSON package is response. Use String content = EntityUtils. toString (response. getEntity (), "UTF-8"); Chinese garbled characters are still involved in decoding, followed
String name = new String(response.getBytes("iso-8859-1"), "UTF-8");
It does not help. Think of the server as if it was cod
When the Android screen switches, the current activity is destroyed, and the data on the activity will be lost.If the checkbox for each item above is ListView, the check box will lose all selected information when the screen is switched.
Solution 1: Add android:configchanges= "Orientation|keyboardhidden" to Androidmanifest.xml's activity tag
Solution 2: force limit activity in horizontal sc
-}The second step is to test the code1 Packagecom.yxh.androidshareprefences01;2 3 ImportJava.util.Map;4 5 Importandroid.app.Activity;6 ImportAndroid.content.Context;7 Importandroid.content.SharedPreferences;8 Importandroid.test.AndroidTestCase;9 ImportAndroid.util.Log;Ten One Public classMyTestextendsAndroidtestcase { A Private StaticString tag= "MyTest"; - - PublicMyTest () { the //TODO auto-generated Constructor stub - } -
standard MD5 encryption in returnbuffer.tostring (); -}Catch(nosuchalgorithmexception e) { to //TODO auto-generated Catch block + E.printstacktrace (); - return""; the } * } $}2, in the Homeactivity.java to use sharedpreferences saved password data to call encryption1 a change to MD5 encryption when you save a password to a file for the first time you set a passwo
Com.example.data_storage_ Share. R;import Com.lc.data_storage_share.sharepreference.loginservice;import Android.os.bundle;import Android.app.activity;import Android.view.menu;import Android.view.view;import Android.view.View.OnClickListener; Import android.widget.button;import android.widget.checkbox;import android.widget.edittext;/* * unit tests need to be in the manifest file */ public class Mainactivity extends Activity {private button button1;//login private button button2;//Cancel private
In Android, there are four main ways to save APK information: sharedpreferences, file (properties), network, SQLite
Sharedpreferences: stores configuration information or user information in the APK and uses key-value pairs. the stored data type can only be basic data types (INT, String, Boolean ..)
Today's demo uses sharedpreferences to save the basic informatio
1. Open the service after the interface startspublic class Uploadlogactivity extends Activity {/** called when the activity is first created. */@Overridepublic void OnCreate (Bundle savedinstancestate) {Super.oncreate (savedinstancestate);Setcontentview (R.layout.main);Intent Intent = new Intent (this,uploadservice.class);StartService (Intent);}2. Background service component is responsible for uploading datapublic class Uploadservice extends Service {private timer timer;Private TimerTask task;P
Android: static variables for Activity data transmission
Using Intent can easily transfer data between different activities. This is also officially recommended, but it also has some limitations.
That is, Intent cannot pass objects that cannot be serialized. We can use static variables to solve this problem.
Obj class
package com.example.activity;public class Obj
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.