Problem in parsing the package Android 2.1
Eclipse.
If install on device signed with proguard *.apk package and try to reinstall it by only signed package get error in parsing the package.
Uninstall the first application with bigger size from device and try install signed package which has a smaller size. Delete from download list previous downloaded *.apk.
This problem occurs when that your downloaded apk file size is less than the
size of the original apk.
If install on device signed with proguard *.apk package and try to reinstall it by only signed package get error in parsing the package.
Uninstall the first application with bigger size from device and try install signed package which has a smaller size. Delete from download list previous downloaded *.apk.
This problem occurs when that your downloaded apk file size is less than the
size of the original apk.
396LW NO topic_id
AD
Další témata ....(Topics)
Click Handler Android Java example source code. Open new class as activity and open URL in browser.
In layout.xml file:
In string.xml
In MainClass.java file
In layout.xml file:
android:layout_height="wrap_content" android:onClick="@string/clickHandler">
In string.xml
myClickHandler
In MainClass.java file
public void myClickHandler(View view) {
switch (view.getId()) {
// open new class as activity
case R.id.btnOpenClass: {
Intent pictureActivity = new Intent(getBaseContext(),
MyClass.class);
startActivity(pictureActivity);
}
break;
case R.id.btnAbout: {
//aboutDialogCreate();
}
break;
// open url
case R.id.btnHome: {
String url = "//android.okhelp.cz/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}break;
}
}// end myClickHandler
// listener .. if click on button will scrolling to mTextView bottom
private OnClickListener mButtonListener = new OnClickListener() {
public void onClick(View v) {
// do something when the button is clicked
int nBottom = mTextView.getBottom();
hScrollView.scrollTo(0, nBottom);
}
};
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");
do while Java example
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
int i = 0;
// first cycle is always executed
do {
System.out.println("Loop: " + i);
System.out.println(arrayOfString[i]);
i++;
}while ( i == -1 );
}
}
/*
Loop: 0
Hello
*/
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
int i = 0;
do {
System.out.println("Loop: " + i);
System.out.println(arrayOfString[i]);
i++;
}while ( i < arrayOfString.length );
}
}
/*
Loop: 0
Hello
Loop: 1
people
Loop: 2
hello
Loop: 3
world!
*/
BufferedReader , FileReader, StringBuilder , readLine, close Java example
Android example
Java example
Android example
String MYFILE = "my_file";
FileInputStream fis = openFileInput(MYFILE);
int c; String sText = "";
while((c=fis.read())!=-1)
{
sText += (char)c; // convert int to char
}
fis.close();
Java example
try {
BufferedReader in = new BufferedReader(new FileReader("myfile.txt"));
StringBuilder strBuilder = new StringBuilder();
String str;
while ((str = in.readLine()) != null) {
strBuilder.append(str);
}
in.close();
} catch (IOException e) {
e.toString();
}
Díl 2.
V prvním dile jsme se něco dozvěděli od XML souborech
Používáme příklad i zip porojekt z https://developer.android.com/training/basics/fragments/creating.html
V tomto díle si rozebereme záludnosti v souboru MainActivity.java.
V prvním dile jsme se něco dozvěděli od XML souborech
a taky jaké označení procesoru pro rok 2016 - Intel® VT-x, Intel® EM64T - musí mít PC pro programování v Android Studiu, tedy hlavně pro spuštění emulátoru - virtuálního telefonu, tabletu atd. jinak nebudete moci testovat aplikace na nejnovějších zařízeních, které tento emulátor umí napodobit.
Dole na stránce odkazu je uvedena minimální konfigurace PC, ale protože Android je již plnokrevný OS, který se neustále rozrůstá, tak tyto hodnoty jsou prakticky nedostatečné a je třeba osadit PC nejnovějšími komponentami.
Používáme příklad i zip porojekt z https://developer.android.com/training/basics/fragments/creating.html
V tomto díle si rozebereme záludnosti v souboru MainActivity.java.
// název balíčku
package com.example.android.fragments;
import android.os.Bundle;
// knihovny nutné pro spuštění na starších zařízeních s verzí Androidu API 4
// API verze a příslušné číslo verze Androidu jsou zde
// https://cs.wikipedia.org/wiki/Historie_verz%C3%AD_Android
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
// HeadlinesFragment je třída se seznamem položek, která díky
// OnHeadlineSelectedListener bude vracet události kliknutí na položku
// Pokud při pokusech přídáme jiný soubor se seznamem, je nutno změnit i název HeadlinesFragment
// na nový název, jinak nic neodchytíme!!!!
public class MainActivity extends FragmentActivity
implements HeadlinesFragment.OnHeadlineSelectedListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// tady se rozhoduje zda si vezme XML pro malé obrazovky, jen s jedním panelem, nebo
// velké se dvěma panely
// Rozhoduje si o tom systém sám, ale můžeme to ovlivnit a pdstrčit mu
// i dvoupanel pro testování - viz předchozí díl //android.okhelp.cz/1-fragments-tutorial-xml-czech-language/
setContentView(R.layout.news_articles);
//// VELKE OBRAZOVKY - layout-large - dual panel /////////
// pokud si systém vybere news_articles.xml z layout-large (dual panel)
// budou fragmenty automaticky naloděny do tagů fragment, kde jsou
// uvedeny absolutní cesty fragmentů!!!!
// např. fragment android:name="com.example.android.fragments.HeadlinesFragment"
// si nalodí sám fragment s linkami - položkami ListView.
// Podobně se sám obslouží při nalodění i fragment s obsahem
// fragment android:name="com.example.android.fragments.ArticleFragment"
// Tyto tagy fragment, s absolutní cestou k fragmentu,
// neumožňují výměnu fragmentu za běhu aplikace!!!!!
// Dynamickou výměnu fragmenut však umožňují kontejnery tagu FrameLayout
//// MALE OBRAZOVKY - jen jeden fragment //////
// Zkontrolujeme, který XML byl naloděn, pokud je activováno R.id.fragment_container
// značí to, že byl vybrán XML ze složky layout, kde je pouze jeden panel a do něj
// vložíme pouze fragment se seznamem, tedy HeadlinesFragment a pak po vybrání položky
// v něm otevřeme ArticleFragment.java s vypsáním obsahu článku atd.
if (findViewById(R.id.fragment_container) != null) {
// Pokud obnovujeme seznam položek vrácením se z předchozího stavu - fragmentu
// pak nepotřebujeme nic dělat a měl bychom opustit tento if, jinak
// dojde překrývání fragmentů, tedy uvídíme překryv textů a dalších elementů původního
// fragmentu fragmentem novým proto uděláme podmínku:
if (savedInstanceState != null) {
return;
}
// vytvoříme instanci HeadlinesFragment s položkami seznamu v ListView
HeadlinesFragment firstFragment = new HeadlinesFragment();
// pokud chceme vložit speciální instrukce pro start odebrané z nějakého Intent,
// odchytíme je zde a vložíme je jako argumenty. Pak je při startu fragmentu
// možno odchytit v onCreate()
firstFragment.setArguments(getIntent().getExtras());
// vložíme fragment do fragment_container FrameLayout-u
// který umožňuje výměnu fragmentů
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, firstFragment).commit();
}
}
// uživatel klikl na nějakou položku ze seznamu v HeadlinesFragment!
public void onArticleSelected(int position) {
// vybereme určitý článek dle pozice položky vybrané v seznamu ListView
// Provedeme kontrolu jestli je naloděn dual panel, nebo jen jednoduchý
ArticleFragment articleFrag = (ArticleFragment)
getSupportFragmentManager().findFragmentById(R.id.article_fragment);
if (articleFrag != null) {
// VELKÉ OBRAZOVKY
// protože je aktivní id R.id.article_fragment z news_articles.xml v layout-large složce
// víme, že aplikace používá dual-panel, dva fragmenty vedle sebe
// zde se volá funkce která je obsažena v třídě v souboru ArticleFragment.java
// a provede patřičné příkazy, v našem případě se
// vypíše obsah článku z třídy Ipsum.java
// sloužící jako úložiště textů přiřazených k jednotlivým
// pozicím - položkám seznamu ListView
articleFrag.updateArticleView(position);
} else {
// MALÉ OBRAZOVKY
// jen JEDEN-PANEL se zobrazuje - vybrán soubor news_articles.xml v layout složce
// musíme vyměnit fragemnty !!!!
// Vytvoříme fragment a doplníme argumenty - hodnoty, poslané např. z HeadlinesFragment.java
// jedná se nám především o pozici položky, na kterou bylo kliknuto v ListView
// tato pozice bude určující pro výběr obsahu pro ArticleFragment
ArticleFragment newFragment = new ArticleFragment();
Bundle args = new Bundle();
args.putInt(ArticleFragment.ARG_POSITION, position);
newFragment.setArguments(args);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// Zde vyměníme původní fragment HeadlinesFragment novým fragmentem s obsahem článku atd.
// Můžeme vyměnit fragment za jiný, protože id fragment_container v layout/news_articles.xml je tagu FrameLayout
transaction.replace(R.id.fragment_container, newFragment);
// addToBackStack umožní uživateli vrátit se zpět na seznam položek v HeadlinesFragment.java
transaction.addToBackStack(null);
// celou transakci předáme ke schválení :)
transaction.commit();
}
}
}
Editace: 2014-02-15 20:45:48
Počet článků v kategorii: 396
Url:problem-in-parsing-the-package-android-2-1