System directories
| Method | Result |
|---|---|
| Environment.getDataDirectory() | /data |
| Environment.getDownloadCacheDirectory() | /cache |
| Environment.getRootDirectory() | /system |
External storage directories
| { | |
| "aps":{ | |
| "alert":{ | |
| "loc-key":"My Localized String", | |
| "loc-args":[ | |
| "First argument", | |
| "Second argument" | |
| ] | |
| }, | |
| "badge":1, |
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
| { | |
| [application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; | |
| return YES; | |
| } |
| -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{ | |
| // Call or write any code necessary to get new data, process it and update the UI. | |
| // The logic for informing iOS about the fetch results in plain language: | |
| if (/** NEW DATA EXISTS AND WAS SUCCESSFULLY PROCESSED **/) { | |
| completionHandler(UIBackgroundFetchResultNewData); | |
| } | |
| if (/** NO NEW DATA EXISTS **/) { |
| <html> | |
| <body> | |
| <h2>Privacy Policy</h2> | |
| <p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended | |
| for use as is.</p> | |
| <p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and | |
| disclosure of Personal Information if anyone decided to use [my|our] Service.</p> | |
| <p>If you choose to use [my|our] Service, then you agree to the collection and use of information in | |
| relation with this policy. The Personal Information that [I|we] collect are used for providing and | |
| improving the Service. [I|We] will not use or share your information with anyone except as described |
| { | |
| "aps":{ | |
| "alert":{ | |
| "loc-key":"My Localized String", | |
| "loc-args":[ | |
| "First argument", | |
| "Second argument" | |
| ] | |
| }, | |
| "badge":1, |
| # How do I test my APN push notification certificates (PEM key)? | |
| # https://www.pubnub.com/knowledge-base/discussion/234/how-do-i-test-my-pem-key | |
| # You can test your PEM key using the following command, which should hang if successful until you press enter: | |
| # openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem | |
| # The above tests the PEM Key in sandbox mode. For production mode, use the following command: | |
| # openssl s_client -connect gateway.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem | |
| # You can also test your PEM Key by running the Python script below using the script below. The usage would be: | |
| # python push_debug.py <CERT_PATH> <DEVICE_TOKEN> | |
System directories
| Method | Result |
|---|---|
| Environment.getDataDirectory() | /data |
| Environment.getDownloadCacheDirectory() | /cache |
| Environment.getRootDirectory() | /system |
External storage directories
| /** | |
| * Definition for binary tree | |
| * public class TreeNode { | |
| * int val; | |
| * TreeNode left; | |
| * TreeNode right; | |
| * TreeNode(int x) { val = x; } | |
| * } | |
| */ | |
| public class Solution { |
| // 判斷 app 是否有安裝 | |
| private static boolean isPkgInstalled(Context context, String pkgName) { | |
| PackageInfo packageInfo = null; | |
| try { | |
| packageInfo = context.getPackageManager().getPackageInfo(pkgName, 0); | |
| } catch (PackageManager.NameNotFoundException e) { | |
| packageInfo = null; | |
| e.printStackTrace(); | |
| } |
| String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()); | |
| // current UNIX time millsecond to yyyy-MM-dd HH:mm:ss |