I am getting well on with Fedora now. However when I was a fresher to Fedora, I have met a lot of problems.
One of them is that When I type some wrong commands It will take too long to respond. It’s totally different from Ubuntu,which I used before. However I like it could quickly reponse even through the command does not exist.
//Let take com.mx.browser as the package nameIntentintent=newIntent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,Uri.parse("package:com.mx.browser"));startActivity(intent);
The following code works. Here take getting String resource for example.
1234567891011121314151617
publicvoidtestUseAndroidString(){Contextcontext=getContext();Resourcesres=null;try{//I want to use the clear_activities string in Package com.android.settingsres=context.getPackageManager().getResourcesForApplication("com.android.settings");intresourceId=res.getIdentifier("com.android.settings:string/clear_activities",null,null);if(0!=resourceId){CharSequences=context.getPackageManager().getText("com.android.settings",resourceId,null);Log.i(VIEW_LOG_TAG,"resource="+s);}}catch(NameNotFoundExceptione){e.printStackTrace();}}
There was a requirement of my work. It requires me to integrated my current project with Facebook SDK for measuring. However this came into my sights.
1
Jar mismatch! Fix your dependencies
The fact is that Both my project and my library project which the former refers to have used android-support-v4.jar. However I realize the two android-support-v4.jar are different after making the md5 hash.
My solution: I use the android-support-v4.jar in my project as the right one. And then replace the one in Facebook SDK with my project one. And then it works.
But my question remains; why it asks me for fix the dependencies to use the same lib jar file?
I guess android will keep only one file for all the references so this will ask developers to make all the same lib all the same.
Sorry for the codeless post.
When I create a new application on Facebook, I meet the problem. Facebook asks me to provide the Key Hash. But it does not show the guidance about how to generate. After Googling, I have found this works for me.
Before executing the following command, you need install openssl
This pragma returns one row for each column in the named table. Columns in the result set include the column name, data type, whether or not the column can be NULL, and the default value for the column. The “pk” column in the result set is zero for columns that are not part of the primary key, and is the index of the column in the primary key for columns that are part of the primary key.
sqlite> .header on
sqlite> PRAGMA table_info(password);
cid|name|type|notnull|dflt_value|pk
0|_id|INTEGER|0||1
1|host|TEXT|0||0
2|username|TEXT|0||0
3|password|TEXT|0||0
#password is the name of a table.
Another answer may also work .schema [tablename] will show the CREATE statement(s) for a table or tables
I was once stucked in How to check Whether a Python module has been installed or not. After Googling, I found this trick.
Python allows user to pass command from out of a python file.See here
1
-c cmd : program passed in as string (terminates option list)
The result if we import an installed module
1234
20:15:45-androidyue~/osc_git/LnxClient (master)$ python -c "import os"20:31:24-androidyue~/osc_git/LnxClient (master)$ echo$?0
#0 means the module has been installed
Now if we import an module which is not installed.
1234567
20:31:41-androidyue~/osc_git/LnxClient (master)$ python -c "import aaa"Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named aaa
20:31:46-androidyue~/osc_git/LnxClient (master)$ echo$?1
#1 means that module is not installed.
As a coder, I am always handling exceptions or errors,or in a word throwables. To impove the release build, I need to collect every throwable information.
And I need to get the information as string and post it to the Bug Collect Server. Now here is an easy trick to get stacktrace from a Throwable
Python provides a lot of method to read output from a just executed shell. However many of them has been deprecated(Not recommened). But subprocess works at present compared to other methods.
A few months ago,I dealed with a task:To build a large amount of apk files. The trick I came up with is to build apk file from the command so that I could use Python to glue all the works. Eventually I made it.And so this post is to make some description about the trick.
Requirements
Setup JDK
Setup Android SDK
Steps
Generate R class file
Compile Java codes(.java files) into classes(.class) files
-encoding encoding Set the source file encoding name, such as EUC-JP and UTF-8. If -encoding is not specified, the platform default converter is used.
-source release Specifies the version of source code accepted, Please Do NOT use Java 7(1.7)
-target version Generate class files that target a specified version of the VM. Class files will run on the specified target and on later versions, but not on earlier versions of the VM. Valid targets are 1.1, 1.2, 1.3, 1.4, 1.5 (also 5), 1.6(also 6), and 1.7 (also 7).
-bootclasspath bootclasspath Cross-compile against the specified set of boot classes. As with the user class path, boot class path entries are separated by colons (:) and can be directories, JAR archives, or ZIP archives.
-d directory Set the destination directory for class files. The directory must already exist; javac will not create it.
As I have suffered a lot using Java 7, It’s recomended to use Java 6
-z Followed by the path to a zip archive. Adds the content of the application package.
-f Followed by the path to a file. Adds the file to the application package.
-rf Followed by the path to a source folder. Adds the java resources found in that folder to the application package, while keeping their path relative to the source folder.
The is an integer that defines the byte-alignment boundaries. This must always be 4 (which provides 32-bit alignment) or else it effectively does nothing.
To be more geek,I began to start an Android App by using adb.Thanks to Google.It’s possible and powerful.
The tool we use to make it is ADB(Android Debug Tool),For more detailed use please visit http://developer.android.com/tools/help/adb.html#shellcommands
Actually What I use here is
1
start [options] <INTENT>
An example is followed.
1234
#Here I want to start MxBrowser app by using ADB17:04:30-androidyue/tmp$ adb shell am start -n com.mx.browser/com.mx.browser.MxBrowserActivity
Starting: Intent {cmp=com.mx.browser/.MxBrowserActivity }Warning: Activity not started, its current task has been brought to the front
the Package name(com.mx.browser) before the slash is provided to determine which app should the intent delivered to.The com.mx.browser.MxBrowserActivity is the destination Activity.
For more explanations about ADB INTENT,please visit http://developer.android.com/tools/help/adb.html#IntentSpec