[Q&A] tabs appearing ABOVE actionbar with custom view in NAVIGATION_MODE_TABS

1
2
3
4
5
6
actionBar.setLogo(new ColorDrawable(Color.TRANSPARENT));
View homeIcon = findViewById(
   Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? 
   android.R.id.home : R.id.abs__home);
((View) homeIcon.getParent()).setLayoutParams(new LinearLayout.LayoutParams(0, 0));
((View) homeIcon).setVisibility(View.GONE);
Tags :

[Q&A] How to solve “Gradle project sync failed. Please fix your project and try again”

1
File -> Invalidate caches / Restart
Tags : ,

[Q&A] android Build.CPU_ABI returns wrong cpu type

there is an experience,
in certain android x86 phone, with certain android os version,

a bundle APK includes

/libs/armeabi/a.so
/libs/armeabi-v7a/a.so
/libs/armeabi-v7a/b.so
/libs/x86/a.so
/libs/x86/b.so

String cpu = Build.CPU_ABI; // armeabi-v7a is returned which is wrong, but in other x86 phones, “x86″ is returned correctly

however, if /libs/armeabi/b.so is added back, or /libs/armeabi is removed

String cpu = Build.CPU_ABI; // x86 is returned correctly

I have not figured out the cause yet,
just keep in mind, there must be same amount shared libraries in each arch folders.

Tags : ,

Handy adb commends for Android

list devices

1
adb devices

install & uninstall apk

1
2
adb install -r ~/Download/myapk.apk
adb uninstall com.ynjan.myapp

start an activity

1
2
adb shell am start com.ynjan.myapp/.MainActivity
adb shell am start com.ynjan.myapp/com.ynjan.myapp.MainActivity

list installed packages

1
adb shell pm list packages -f

reboot

1
adb reboot

enter devices’s shell

1
adb shell

make input in shell

1
2
3
4
5
6
7
usage: input ... 
   input text <string> [delay]
   input keyevent <key code number or name>
   input [touchscreen|touchpad] tap <x> <y>
   input [touchscreen|touchpad] swipe <x1> <y1> <x2> <y2>
   input trackball press
   input trackball roll <dx> <dy>

for example

1
2
3
4
#unlock screen
input keyevent 82
#device power on/off
input keyevent 26

android key codes

clear application data

1
adb shell pm clear com.ynjan.myapp

Logging

1
2
3
4
5
6
7
8
9
# log with tag
adb logcat -s TAG_NAME_1
# log with priority
adb logcat "*:PRIORITY"
adb logcat -s TAG_NAME:PRIORITY
# log with keyword (regex)
adb logcat | grep "SOME_KEYWORDS"
# clear log
adb logcat -c
Tags : , ,

[QA]How to set php upload_max_filesize in .htaccess?

php_value upload_max_filesize 10M

need enable AllowOverride in root

AllowOverride Options
Tags :

[QA]How to sort NSArray in 3 ways

Compare method

1
2
3
4
5
6
- (NSComparisonResult)compare:(Person *)otherObject {
    return [self.birthDate compare:otherObject.birthDate];
}
 
NSArray *sortedArray;
sortedArray = [drinkDetails sortedArrayUsingSelector:@selector(compare:)];

NSSortDescriptor

1
2
3
4
5
6
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"birthDate"
                                              ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray;
sortedArray = [drinkDetails sortedArrayUsingDescriptors:sortDescriptors];

Blocks

1
2
3
4
5
6
NSArray *sortedArray;
sortedArray = [drinkDetails sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
    NSDate *first = [(Person*)a birthDate];
    NSDate *second = [(Person*)b birthDate];
    return [first compare:second];
}];
Tags : ,

XMPP commons

get server version

<iq type="get" to="test2@ynjan.com/cs101" id="aabea">
<query xmlns="jabber:iq:version"/>
</iq>
<iq from="test2@ynjan.com/cs101" type="result" to="test2@ynjan.com/cs101" id="aabea">
<query xmlns="jabber:iq:version">
<name>Tigase</name>
<version>7.0.1-b3810/2cf8a210 (2015-03-25/17:34:46)</version>
<os>Mac OS X-x86_64-10.9.5, Java HotSpot(TM) 64-Bit Server VM-24.75-b04-Oracle Corporation</os>
</query>
</iq>

set my vcard

<iq type="set" id="aabfa">
<vCard xmlns="vcard-temp"> 
<NICKNAME>test2 nick</NICKNAME> 
</vCard>
</iq>
<iq type="result" id="aabfa" to="test2@ynjan.com/cs101"/>

get vcard

<iq type="get" to="test1@ynjan.com" id="aac1a">
<vCard xmlns="vcard-temp"/> 
</iq>
<iq from="test1@rd.connexionone.com" type="result" to="test2@rd.connexionone.com/rd" id="aac1a"> 
<vCard xmlns="vcard-temp"> 
<NICKNAME>test1 nick</NICKNAME> 
</vCard> 
</iq>
Tags :

[QA]How to get mimeType of file in a Android

    public static String getMimeType(String url) {
        String type = "*/*";
        String extension = MimeTypeMap.getFileExtensionFromUrl(url);
        if (extension != null) {
            MimeTypeMap mime = MimeTypeMap.getSingleton();
            type = mime.getMimeTypeFromExtension(extension.toLowerCase());
        }
        return type;
    }

XMPP Roster

xmpp roster SD

 

  1. Add Roster
    1. Add Roster
      <iq type="set" id="aadba">
       <query xmlns="jabber:iq:roster">
        <item jid="b@ynjan.com"/>
       </query>
      </iq>
    2. Subscribe
      <presence type="subscribe" to="b@ynjan.com">
       <nick xmlns="http://jabber.org/protocol/nick">_b_</nick>
      </presence>
    3. Subscribed
      <presence type="subscribed" to="a@ynjan.com" from="b@ynjan.com">
      </presence>
  2. Remove Roster
    <iq type="set" id="aadda">
    <query xmlns="jabber:iq:roster">
    <item subscription="remove" jid="b@ynjan.com"/>
    </query>
    </iq>
Tags : ,

[QA]SMTP Error: Could not authenticate when using WP SMTP Gmail

Gmail does not allow low security applications to access now by default

https://support.google.com/accounts/answer/6010255

Tags : ,