3 android development of small knowledge

2011-01-09  来源:本站原创  分类:Mobile  人气:106 

1. Start the program without animation

Java code

  1. myIntent.setFlags (Intent.FLAG_ACTIVITY_NO_ANIMATION); / / 1.5 to be used, so that you can not animate the
  2. getWindow (). setWindowAnimations (0) / / 1.6 to be used, do not forget to put this activity

myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);//1.5 You should use, so that you can not have animation effects
getWindow().setWindowAnimations(0)//1.6 You should use, do not forget in activity

2.SD card create a directory

Java code

  1. File wallpaperDirectory = new File ("/ sdcard / Wallpaper /");
  2. wallpaperDirectory.mkdirs ();
  3. File outputFile = new File (wallpaperDirectory, filename);
  4. FileOutputStream fos = new FileOutputStream (outputFile);

File wallpaperDirectory = new File("/sdcard/Wallpaper/");
wallpaperDirectory.mkdirs();
File outputFile = new File(wallpaperDirectory, filename);
FileOutputStream fos = new FileOutputStream(outputFile);

Note To add permissions Oh

Xml Code

  1. <Uses-permission android: name = "android.permission.WRITE_EXTERNAL_STORAGE" />

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

3. Text effect of the middle horizontal line

Java code

  1. priceTV.setText ("Price: 2.00 USD");
  2. priceTV.getPaint (). setFlags (Paint.STRIKE_THRU_TEXT_FLAG);

priceTV.setText(" Price :2.00 Yuan ");
priceTV.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

4.android SQLite database using transaction operation

Java code

  1. SQLiteDatabase db = ....;
  2. db.beginTransaction ();// start transaction
  3. try {
  4. db.execSQL ("insert into person (name, age) values (?,?)", new Object [] {" Joe Smith "
  5. 4});
  6. db.execSQL ("update person set name =? where personid =?", new Object [] {"John Doe", 1});
  7. db.setTransactionSuccessful ();// Calling this method in the implementation of the endTransaction () to submit the present matter
  8. Service, if you do not call this method rolls back the transaction
  9. } Finally {
  10. db.endTransaction ();// decision by the Panel to submit a sign of affairs, or roll back the transaction
  11. }
  12. db.close ();

SQLiteDatabase db = ....;
db.beginTransaction();// Begin transaction
try {
        db.execSQL("insert into person(name, age) values(?,?)", new Object[]{" John ", 

4});
        db.execSQL("update person set name=? where personid=?", new Object[]{" Dick ", 1});
        db.setTransactionSuccessful();// In the implementation of this method is called to endTransaction() Commit the current 

 If the do not call this method rolls back a transaction
} finally {
        db.endTransaction();// By Mark decide whether to commit the transaction, is to roll back the transaction
}
db.close();

5. SmsMessage questions on the SMS class

Java code

  1. public void onReceive (Context context, Intent intent) {
  2. / / TODO Auto-generated method stub
  3. Log.d (TAG, "---> onReceive, SMS reach ");
  4. Bundle bundle = intent.getExtras ();
  5. if (bundle! = null) {
  6. Object [] pdus = (Object []) bundle.get ("pdus");
  7. SmsMessage [] messages = new SmsMessage [pdus.length];
  8. for (int i = 0; i <pdus.length; i + +) {
  9. messages = SmsMessage.createFromPdu ((byte []) pdus);
  10. }
  11. for (SmsMessage smsMessage: messages) {
  12. from = smsMessage.getDisplayOriginatingAddress ();
  13. data = smsMessage.getDisplayMessageBody (). trim ();
  14. Log.d (TAG, from + "" + data);
  15. / / Process content
  16. response (context, data);
  17. }
  18. }
  19. }
相关文章
  • 2 android development of small knowledge 2011-01-09

    1. Control configuration xml in the interesting properties: android: background You can set the background for the following two methods transparent: "@ android: color / transparent" and "@ null". Note that the default TextView is tran

  • 3 android development of small knowledge 2011-01-09

    1. Start the program without animation Java code myIntent.setFlags (Intent.FLAG_ACTIVITY_NO_ANIMATION); / / 1.5 to be used, so that you can not animate the getWindow (). setWindowAnimations (0) / / 1.6 to be used, do not forget to put this activity m

  • Classic android development site 2010-04-22

    [Android Chinese original order] android development of the classical site (2010-02-26 01:29:19) Reprinted 1, the official website, including android branch version and handset manufacturers website 1.Android - an open handset alliance project http:/

  • Introduction android development (change) 2010-05-24

    Environmental structures Before you begin, you need to prepare the following environmental and procedural Necessary Microsoft Windows XP / Microsoft Windows Vista operating system Android SDK 1.1r1 Java Development Kit (JDK) v6.0 or above eclipse-jee

  • Android Development Resources Summary 2010-09-03

    1, eoe Android Developer Forum Currently the first Android developer community is very busy popular gathering Bushao Android development of the master, the development of big problems can be resolved here, the biggest feature is the Web site regularl

  • Full summary Android Development Resources 2010-09-03

    1, eoe Android Developer Forum At present the earliest of the Android developer community is very busy gathering a lot of popular Android development of the master, the development of big problems can be resolved here, the site features the largest r

  • Android Development Resources (rpm) 2010-10-19

    Transfer from: http://android.group.javaeye.com/group/topic/21364 1, eoe Android Developer Forum At present, the first Android developer community is very busy popular gathering a lot of Android in the development of a master, the problems encountere

  • Full summary Android development resources (to MatthewChen Piscesky) 2010-12-21

    Full summary Android Development Resources 1, eoe Android Developer Forum At present, the first Android developer community is very busy popular gathering a lot of Android in the development of a master, the problems encountered in developing them ca

  • Android Development FAQ 2010-12-23

    Android Getting Started FAQ 1, Q: What is Android? A: Android means the original meaning of the term "robot", is also Google on November 5, 2007 announced the open source Linux-based mobile operating system, the name of the platform by the opera

  • Android development of a number of important points online 2011-01-13

    From network 1. Android Single Instance Methods We all know that Android platform is not the task manager, and defenders within the App Activity history stack to achieve a window display and destruction, for the conventional view is from the shortcut

  • Android development, how the implementation of POST requests 2010-03-29

    A brief description of the last article I had in the Android development, how to send a Get request, under this article we explore how to implement an Android development of Post requests. Get under the First, we first understand the difference betwe

  • Configuration android development environment 2010-03-29

    Heard about google's android programmers salary is high ah. Today, interest in try. Then install the development environment. Still using MyEclispe6.5. To install android development of plug-ins. So, after I finished writing directly to Chinese. 1. H

  • Android development environment to build Record 2010-03-29

    Android development environment to build is actually very simple, need time to pay attention in the development of some of the details. In this paper, a running account, in the form of record of the author Installation and Configuration Android devel

  • Android development environment configuration 2010-03-29

    G2 was infatuated for two weeks, was deeply into drugs. . TIM had risen to more than 2300 black, sad. . Frustration on the other milestone - -- Configure an Android development environment, to experience. To prepare things: 1) IDE. Doubt myeclipse, a

  • Android Development of four methods to save the data 2010-04-27

    Android Development of four methods to save data in this paper the sea from the East Fangshang Zhi Shen CSDN blog, please mark reproduced Source: http://blog.csdn.net/sdhjob/ In the Android development will be exposed to four kinds of data storage me

  • Android development environment for building Record 2010-03-08

    Construction of Android development environment is simple, requires some attention to detail in the development time. This article records the author in the form of a running account configuration Android development environment installed encountered

  • Android development environment set up 2010-03-18

    Android development is now in full swing, succeed is not very busy, and studied under the record here how to set up in the windows in the Android development environment on their own is a record entry of new brothers and sisters for reference! (1) In

  • Android Development Environment (Introduction) 2010-05-10

    Software to be installed: 1.jdk 6 2.Eclipse 3.4 3.Android SDK 1.0 4.ADT (Android's Eclipse plug-in) The first step: download the software needed to install jdk, unzip Eclipse and Android SDK. Step Two: Configure environment variables, the Android SDK

  • android development must-see resource URL 2010-05-24

    Must see collection of some android development resources, will continue to add: Google Android Development official website Google Android Group developed Official Forum stackoverflow.com famous Android Forum Android Open Source Project Android sour

  • Android Development - Display cell phone sensor 2010-06-11

    Android development kit standard with 8 sensors: Sensor.TYPE_ACCELEROMETER Accelerometer (X, Y, Z) m/s2 Sensor.TYPE_GYROSCOPE Gyro (X, Y, Z) degrees Sensor.TYPE_LIGHT Light (single) lux Sensor.TYPE_MAGNETIC_FIELD Magnetometer (X, Y, Z) microteslas Se