Date getDate is deprecated Java Android
Date getDate is deprecated Java Android example code:
long dayInMili = 100000000;
GregorianCalendar calToDay = new GregorianCalendar();
int nD = calToDay.get((Calendar.MILLISECOND)); // +dayInMili;
System.out.println(nD);
long lTime = calToDay.getTimeInMillis();
System.out.println(lTime);
Date dtA = new Date(lTime); // today
///@SuppressWarnings("deprecation")
int nD1 = dtA.getDate(); // DEPRECATED Day Of Month 1 - 31
System.out.println(nD1+" nD1");
GregorianCalendar cal = new GregorianCalendar();
int nD2 = calToDay.get(Calendar.DATE); // Day Of Month
System.out.println(nD2+" nD2");
cal.setTimeInMillis(lTime+dayInMili);// setTime(dtA);
int nD3 = cal.get(Calendar.DATE); // Day Of Month + 1 day
System.out.println(nD3+" nD3");
396LW NO topic_id
AD
Další témata ....(Topics)
Create file restartADB.bat in folder
c:\Program Files\Android\android-sdk-windows\platform-tools\
Write into restartADB.bat this code:
Save restartADB.bat file.
If you want restart adb.exe server, run restartADB.bat by double click on icon.
Next example:
[caption id="attachment_778" align="alignleft" width="300" caption="ADB server restart by command line"]
[/caption]
Try restart ADB if this or similar errors:
Emulator] emulator: emulator window was out of view and was recentred
c:\Program Files\Android\android-sdk-windows\platform-tools\
Write into restartADB.bat this code:
adb kill-server && adb start-server
pause
Save restartADB.bat file.
If you want restart adb.exe server, run restartADB.bat by double click on icon.
Next example:
- Open Total Commander
- Open folder with adb.exe usually in
c:\Program Files\Android\android-sdk-windows\platform-tools\ - Put into command line command: adb kill-server && adb start-server and press Enter
[caption id="attachment_778" align="alignleft" width="300" caption="ADB server restart by command line"]

Try restart ADB if this or similar errors:
Emulator] emulator: emulator window was out of view and was recentred
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
TextView textView = new TextView(this);
textView.setText("Text View ");
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
layout.addView(textView, p);
Button buttonView = new Button(this);
buttonView.setText("Button");
buttonView.setOnClickListener(mThisButtonListener);
layout.addView(buttonView, p);
}
private OnClickListener mThisButtonListener = new OnClickListener() {
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Hello !",
Toast.LENGTH_LONG).show();
}
};
}
Best of SQLite explorer and admin download for SQLite 2.x and SQLite 3.x in separated folders.
Download Explorers SQLite 2.x and SQLite 3.x in separated folders
Download Explorers SQLite 2.x and SQLite 3.x in separated folders
Locale lc = Locale.getDefault(); // default now locale on device
String sCountry = lc.getCountry(); // CZ
lc = new Locale("fr","FR"); //FRANCE .. Locale(language, country);
String sCountry2 = lc.getDisplayCountry(); // Francie
Locale locale = Locale.GERMAN;
String sCountry3 = locale.getDisplayCountry(); // ""
Locale locale = Locale.GERMAN;
DateFormat formatter = new SimpleDateFormat("HH:mm:ss zzzz", locale);
String s = formatter.format(new Date());//13:40:39 GMT+00:00
// array of locales
Locale[] locales = { new Locale("fr", "FR"), new Locale("de", "DE"),
new Locale("en", "US") };
Locale locale = Locale.US;
// for date
DateFormat dateFormatterEurope = DateFormat.getDateInstance(DateFormat.DEFAULT,
Locale.GERMANY);
Calendar myCalendar = Calendar.getInstance();
String sDate = dateFormatterEurope.format(myCalendar.getTime());
final byte[] langBytes = locale.getLanguage().getBytes(Charsets.US_ASCII);
// UTF-8 most widely used text format for to properly display of text
final Charset utfEncoding = Charsets.UTF_8;
String text = "ěščřžýáíéůú";
final byte[] textBytes = text.getBytes(utfEncoding);
// other Locale
CANADA
CANADA_FRENCH
CHINA
CHINESE
ENGLISH
FRANCE
FRENCH
GERMAN
GERMANY
ITALIAN
ITALY
JAPAN
JAPANESE
KOREA
KOREAN
PRC // Locale constant for zh_CN.
ROOT // Locale constant for the root locale.
SIMPLIFIED_CHINESE
TAIWAN
TRADITIONAL_CHINESE Locale constant for zh_TW.
UK
US
AdMob in Android emulator not visible?
You have to using some from this libraries:
GoogleAdMobAdsSdk-4.3.1.jar
GoogleAdMobAdsSdk-6.0.1.jar
GoogleAdMobAdsSdk-6.2.1.jar
AndroidManifest.xml
onCreate in your Activity.java
main.xml (res/layout)
You have to using some from this libraries:
GoogleAdMobAdsSdk-4.3.1.jar
GoogleAdMobAdsSdk-6.0.1.jar
GoogleAdMobAdsSdk-6.2.1.jar
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
package="cz.okhelp.admob"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="13"
android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<meta-data
android:value="a14d932xxxxxxxx"
android:name="ADMOB_PUBLISHER_ID" />
<activity android:name=".AdmobActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
onCreate in your Activity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdViw adView = new AdView(this, AdSize.BANNER, "a14d932xxxxxxxxx");//MY_AD_UNIT_ID
LinearLayout layout = (LinearLayout)findViewById(R.id.idReklamaLayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest();
//adRequest.setTesting(true);
adRequest.setGender(AdRequest.Gender.MALE);
adView.loadAd(adRequest);
}
main.xml (res/layout)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:id="@+id/idReklamaLayout"
android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="3" />
</LinearLayout>
Editace: 2012-12-07 14:42:23
Počet článků v kategorii: 396
Url:date-getdate-is-deprecated-java-android