Android: Unterschied zwischen den Versionen

Aus wiki
Wechseln zu: Navigation, Suche
(Let Android Studio fetch the sources with gradle)
 
(21 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
 +
* [[Android_Library_Jitpack|Android Library creation on Jitpack]]
 +
 
=== Exclude "TAG" from LogCat (Eclipse-View) ===
 
=== Exclude "TAG" from LogCat (Eclipse-View) ===
 
  tag:^(?!(TAG))
 
  tag:^(?!(TAG))
Zeile 8: Zeile 11:
 
  adb shell pm clear ch.christofbuechi.xyz
 
  adb shell pm clear ch.christofbuechi.xyz
  
 +
=== non-root: extract database from application ===
 +
adb backup -f /tmp/data.ab -noapk ch.christofbuechi.tuningeventsschweiz (you have to agree on the device itself)
 +
cat /tmp/data.ab | (dd bs=24 count=0 skip=1; cat) | zlib-flate -uncompress > appbackup.tar
 +
tar xvf appbackup.tar
 +
(show files in explorer, database is in "db"-folder)
  
=== Reader to String ===
+
=== fragmentmanager show fragments in stack ===
 +
for(int entry = 0; entry < getActivity().getSupportFragmentManager().getBackStackEntryCount(); entry++){
 +
  Log.i("check fragments", "Found fragment at " + entry + ": " + getActivity().getSupportFragmentManager().getBackStackEntryAt(entry).getId());
 +
}
 +
 
 +
=== setBackground for View in onViewCreated ===
 +
view.setBackgroundColor(view.getContext().getResources().getColor(android.R.color.white ));
 +
 
 +
=== Reader to String code ===
 
  Reader read = response.body().charStream();
 
  Reader read = response.body().charStream();
 
  int intValueOfChar;
 
  int intValueOfChar;
Zeile 19: Zeile 35:
 
  Log.d(this.getClass().getName(), targetString);
 
  Log.d(this.getClass().getName(), targetString);
  
=== Reader to String code ===
+
=== Let Android Studio fetch the sources with gradle ===
<code>Reader read = response.body().charStream();
+
add:
  int intValueOfChar;
+
  apply plugin: 'idea'
  String targetString = "";
+
  idea {
  while ((intValueOfChar = read.read()) != -1) {
+
    module {
targetString += (char) intValueOfChar;
+
        // if you hate browsing Javadoc
 +
        downloadJavadoc = false
 +
   
 +
        // and love reading sources :)
 +
        downloadSources = true
 +
    }
 
  }
 
  }
  read.close();
+
source: http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
  Log.d(this.getClass().getName(), targetString);</code>
+
 
 +
=== Android Button Selector Snippet ===
 +
copied from here:
 +
  http://stackoverflow.com/questions/13443534/android-button-select-and-press-drawable
 +
button_sel.xml
 +
 
 +
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 +
      android:shape="rectangle">
 +
    <gradient android:startColor="@color/azulado"
 +
              android:endColor="@color/azulBrillante"
 +
              android:angle="270" />
 +
    <corners android:radius="@dimen/corner_radius" />
 +
    <stroke android:width="2px"
 +
            android:color="@color/blanco" />
 +
</shape>
 +
button_unsel.xml
 +
 
 +
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 +
      android:shape="rectangle">
 +
    <gradient android:startColor="@color/botonesD"
 +
              android:endColor="@color/botones"
 +
              android:angle="270" />
 +
    <corners android:radius="@dimen/corner_radius" />
 +
    <stroke android:width="2px"
 +
            android:color="@color/blanco" />
 +
  </shape>
 +
button.xml
 +
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 +
    <item android:drawable="@drawable/button_sel" android:state_selected="true" />
 +
    <item android:drawable="@drawable/button_sel" android:state_pressed="true" />
 +
    <item android:drawable="@drawable/button_unsel" />
 +
</selector>
 +
 
 +
=== Divider android ===
 +
 
 +
  <View
 +
    android:id="@+id/divider"
 +
        android:layout_width="fill_parent"
 +
        android:layout_height="1px"
 +
        android:layout_marginTop="@dimen/margin_big"
 +
    android:layout_below="@id/card_operation_item_date_description_container"
 +
        android:background="@android:color/darker_gray" />
 +
 
 +
=== Various problem fixes on Android ===
 +
[[Android_Problem_fixes|Android Fixes]]

Aktuelle Version vom 30. Januar 2017, 16:47 Uhr

Exclude "TAG" from LogCat (Eclipse-View)

tag:^(?!(TAG))

Uninstall Application from CLI

adb uninstall ch.christofbuechi.xyz

delete just user-data from application

adb shell pm clear ch.christofbuechi.xyz

non-root: extract database from application

adb backup -f /tmp/data.ab -noapk ch.christofbuechi.tuningeventsschweiz (you have to agree on the device itself)
cat /tmp/data.ab | (dd bs=24 count=0 skip=1; cat) | zlib-flate -uncompress > appbackup.tar
tar xvf appbackup.tar
(show files in explorer, database is in "db"-folder)

fragmentmanager show fragments in stack

for(int entry = 0; entry < getActivity().getSupportFragmentManager().getBackStackEntryCount(); entry++){
 Log.i("check fragments", "Found fragment at " + entry + ": " + getActivity().getSupportFragmentManager().getBackStackEntryAt(entry).getId());
}

setBackground for View in onViewCreated

view.setBackgroundColor(view.getContext().getResources().getColor(android.R.color.white ));

Reader to String code

Reader read = response.body().charStream();
int intValueOfChar;
String targetString = "";
while ((intValueOfChar = read.read()) != -1) {
targetString += (char) intValueOfChar;
}
read.close();
Log.d(this.getClass().getName(), targetString);

Let Android Studio fetch the sources with gradle

add:

apply plugin: 'idea'
idea {
   module {
       // if you hate browsing Javadoc
       downloadJavadoc = false

       // and love reading sources :)
       downloadSources = true
   }
}

source: http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html

Android Button Selector Snippet

copied from here:

http://stackoverflow.com/questions/13443534/android-button-select-and-press-drawable

button_sel.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="rectangle">
   <gradient android:startColor="@color/azulado" 
             android:endColor="@color/azulBrillante"
             android:angle="270" />
    <corners android:radius="@dimen/corner_radius" />
    <stroke android:width="2px" 
            android:color="@color/blanco" />
</shape>

button_unsel.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="rectangle">
   <gradient android:startColor="@color/botonesD" 
             android:endColor="@color/botones"
             android:angle="270" />
   <corners android:radius="@dimen/corner_radius" />
   <stroke android:width="2px" 
           android:color="@color/blanco" />
</shape>

button.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:drawable="@drawable/button_sel" android:state_selected="true" />
   <item android:drawable="@drawable/button_sel" android:state_pressed="true" />
   <item android:drawable="@drawable/button_unsel" />
</selector>

Divider android

 <View
   	android:id="@+id/divider"
       android:layout_width="fill_parent"
       android:layout_height="1px"
       android:layout_marginTop="@dimen/margin_big"
   	android:layout_below="@id/card_operation_item_date_description_container"
       android:background="@android:color/darker_gray" />

Various problem fixes on Android

Android Fixes