1. Get contact information from SMS
Java code
- Contactitem getcontactbyaddr (context, final smsitem SMS ){
- Uri personuri = URI. withappendedpath (
- Contactscontract. phonelookup. content_filter_uri, SMS. maddress );
- Cursor cur = context. getcontentresolver (). Query (personuri,
- New String [] {phonelookup. display_name },
- Null, null, null );
- If (cur. movetofirst ()){
- Int nameidx = cur. getcolumnindex (phonelookup. display_name );
- Contactitem item = new contactitem ();
- Item. mname = cur. getstring (nameidx );
- Cur. Close ();
- Return item;
- }
- Return NULL;
- }
2. Retrieve and display images from gallery
Java code
- Protected void onactivityresult (INT requestcode, int resultcode, intent imagereturnedintent ){
- Super. onactivityresult (requestcode, resultcode, imagereturnedintent );
- Switch (requestcode ){
- Case req_code_pick_image:
- If (resultcode = result_ OK ){
- Uri selectedimage = imagereturnedintent. getdata ();
- String [] filepathcolumn = {mediastore. Images. Media. Data };
- Cursor cursor = getcontentresolver (). Query (selectedimage, filepathcolumn, null );
- Cursor. movetofirst ();
- Int columnindex = cursor. getcolumnindex (filepathcolumn [0]);
- String filepath = cursor. getstring (columnindex );
- Cursor. Close ();
- Bitmap yourselectedimage = bitmapfactory. decodefile (filepath );
- }
- }
- }
3. Use toast in the service
Java code
- Public class connectionservice extends Service {
- Private handler = new handler ();
- Public void restartconnection (){
- Int sleeptime = reconnectcounter * min_recon_wait;
- If (sleeptime> max_recon_wait ){
- Sleeptime = max_recon_wait;
- }
- String MSG = "the connection has been lost. Restart attempt will start in:" + sleeptime/1000 + "seconds ";
- (New timer (). Schedule (
- New timertask (){
- Public void run (){
- Handler. Post (New runnable (){
- Public void run (){
- Toast. maketext (getapplicationcontext (), "MSG", Toast. length_long). Show ();
- Reconnectcounter ++;
- This. startconnectionthread ()
- }
- });
- }
- }, Sleeptime );
- } // End restartconnection
- } // End connectionservice
4. Disable webview zoom-in and out
XML Code
- <Meta content = 'width = device-width; initial-scale = 1.0; maximum-scale = 1.0; User-scalable = 0; 'name = 'viewport'/>
- <Meta name = "viewport" content = "width = device-width"/>
5. Use the margin code to realize the empty outbound distance around the view
Java code
- Extview TV = (textview) findviewbyid (R. Id. my_text_view );
- Linearlayout. layoutparams Params = (linearlayout. layoutparams) TV. getlayoutparams ();
- Params. setmargins (0, 0, 10, 0); TV. setlayoutparams (Params );
6. Use of internal classes
XML Code
- <View class = "com. Android. notepad. noteeditor $ myedittext"
- Id = "@ + ID/Note"
- Android: layout_width = "fill_parent"
- Android: layout_height = "fill_parent"
- Android: Background = "@ Android: drawable/empty"
- Android: padding = "10dip"
- Android: scrollbars = "vertical"
- Android: fadingedge = "vertical"/>
7. Note:
Java code
- On the simulator, replace 127.0.0.1 and localhost with 10.0.2.2.
- In the LAN environment, you can use 192.168.0.x or 192.168.1.x (depending on the specific configuration) to connect to the local machine.
8. decompile the files in the APK or generate the APK:
Java code
- Declare in advance that relevant tools must be used
- Decompile XML into a format that we can understand
- Java-jar axmlprinter2.jar ***. xml> ***. txt
- Compile classes. Dex to the classout of the current directory.
- Java-jar baksmali. jar-O classout/classes. Dex
- The file for compiling classout is classes. Dex.
- Java-jar smali. Jar classout/-O classes. Dex