顯示具有 Programming 標籤的文章。 顯示所有文章
顯示具有 Programming 標籤的文章。 顯示所有文章

2012年6月27日 星期三

Sign Google App


<quoted from other web>
You need to create Release Key for Signing your Application.
Step : 1 Right Click Project->Export Application->Select you Project->Next->Select new Keystore -> Complete all rest Steps
Step : 2 Note down your Alias name and Password given.
Step : 3 Now if you Complete all process of Filling Details you will get one .apk file and keystore file in you stored location.
Step : 4 Now Again Right Click Project->Export Application->Select you Project->Next->Use Existing Keystore -> Give location and password->Next
Step : 5 Now you alias name will comes in your Drop Down->Select it -> Enter Password -> Next
Step : 6 It will ask for location to store your final .apk file.
Step : 7 Select your location and store.
Step : 8 Now this Final .apk file is Your Signed Application.
Note : Keep this keystore file for further updated of your Application in Android Market ,also keep track of your Alias name and Password

GCM (Google Cloud Messaging)

http://developer.android.com/guide/google/gcm/gs.html

Change from C2DM to GCM on 28 Jne 2012

According to the document, migration is simply change the email into API key.


Migration is simple! The only change required in the application is replacing the email account passed in the sender parameter of the registration intent with the project ID generated when signing up for the new service. For example:
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
// sets the app name in the intent
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
registrationIntent.putExtra("sender", senderID);
startService(registrationIntent);

2012年6月1日 星期五

LumiaChallenge 2012

 剛提交了三個作品到 Nokia 參加 LumiaChallenge 2012 的比賽,順便做個記錄。

CDict - When we type English passage, we always forget a word or how to spell a word.  This movie shows how to type the word using the language you know (in this example Chinese) directly into the editor and do the translation in cloud (Microsoft translation in this example) instantly.  The program can  intelligently check the Chinese inside.  Thus, it saves lots of time to check from web or dictionary and come back to type the passage.  In this movie, one sentence is for demo purpose.  In future, a whole passage can be done in any-input-language to any-output-language.
video demo - http://youtu.be/4ekTQBW696M  

人生計算機 - 我們每天都不自覺地問到人生的問題。本程式嘗試給出一個參考。透過古人的生活體驗,歸納出來的人生法則,我們把它量化做成這程式。程式包括二部份。1.每天的開心指數 2.人生的反思首部份只要把相關出生年月日輸入,程式就會把結果化為圖像。第二部份,用家輸入英文,程式會給出所佔人生部份的比例。 *以上並非隨機結果,亦只作為參考用途。

QueuEasy
With QueuEasy, we do not need to spend time on service waiting anymore. We can shop around until the shop pushes you back. This app requires to work with www.queueasy.com

2012年5月28日 星期一

iOS token



From : http://davehiren.blogspot.com/2012/03/get-device-token-for-apple-push.html


Get device token for apple push notifications in sencha touch and phone gap

Hello,

Recently I was working on Apple push notifications with sencha touch and phonegap project. Requirement was to get device token in JavaScript file so that it can be sent to server for getting push notifications. For that first thing we need to do is register device to get Push notifications.

Please make sure that you have real apple device like iPad, iPhone or iPod touch to test this. This will not work in Simulator.

To register device for push notifications add following in your AppDelegate.m file.  Find method


- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

Also add following line to define token variable.


@synthesize token;


and add following code at end of the method.


NSLog(@"Registering for push notifications...");    
    [[UIApplication sharedApplication] 
     registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeAlert | 
      UIRemoteNotificationTypeBadge | 
      UIRemoteNotificationTypeSound)];

This will register device for getting push notifications. Please make sure that you have added provisioning profile which configured with non wild card app id and app is configured to receive  push notifications in your development portal. Also you need valid developer certificate.

After that you need to add following methods at end of the file.

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 

    
    self.token = [[[[deviceToken description]
                    stringByReplacingOccurrencesOfString: @"<" withString: @""]
                   stringByReplacingOccurrencesOfString: @">" withString: @""]
                  stringByReplacingOccurrencesOfString: @" " withString: @""];
    
    NSLog(@"My token is: %@", self.token);
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { 
    
    NSString *str = [NSString stringWithFormat: @"Error: %@", err];
    NSLog(str);    
    
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    
    for (id key in userInfo) {
        NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
    }    
    
}


This will get device token and store it to token. Now to send this token to JavaScript we will create a phonegap plugin. Please make sure that this code will work with Phonegap version 1.5.0. They named this version as Cardova.

First create folder inside plugins folder of your project folder and name it as PushToken and add two files to it PushToken.m and PushToken.h

Open PushToken.h file and add following code to it.



#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>

@interface PushToken : CDVPlugin{
    
    NSString* callbackID;  
}

@property (nonatomic, copy) NSString* callbackID;

- (void) getToken:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

@end



Now open PushToken.m file and add following code to it.

#import "PushToken.h"
#import "AppDelegate.h"

@implementation PushToken

@synthesize callbackID;

-(void)getToken:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options  {
    self.callbackID = [arguments pop];
    
    NSString *token = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).token;
    
    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[token stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    
    if(token.length != 0)
    {
        [self writeJavascript: [pluginResult toSuccessCallbackString:self.callbackID]];
    }else {    
        [self writeJavascript: [pluginResult toErrorCallbackString:self.callbackID]];
    }
}

@end

Now we have to map this plugin. For that open Cordova.plist file and following key value pair to it.

PushToken : PushToken

After that open AppDelegate.h file and add following line to it.

@property (retain, nonatomic) NSString* token;

That's it of phonegap side now we have to create JavaScript file form where we will execute this plugin code. Create JavaScript file with name PushToken.js and add it to www folder. Add following code to it.

var PushToken = {
    getToken: function(types, success, fail) {
        return Cordova.exec(success, fail, "PushToken", "getToken", types);
    }
};

Add link of this JavaScript file to your index.html page after phonegap JavaScript file. To get device token wherever you want use following code.


PushToken.getToken(     
                     ["getToken"] ,           
                     function(token) {
                              global.token = token; 
                     },
                     function(error) {
                              console.log("Error : \r\n"+error);      
                     }
          );

That's it and you have your device token.

2012年5月8日 星期二

PUSH on Android and Windows Phone

做了個測試把 Push notification 直接到兩個不同 OS - Android / WP.  好厲害超快亦機乎同時到達


2012年4月29日 星期日

Windows 7 Push Notification

From web: $uri="http://db3.notify.live.net/throttledthirdparty/01.00/AAHCuoXMr7ucQphPazXmhi9_AgAAAAADDAAAAAQUZm52OkJCMjg1QTg1QkZDMkUxREQ"; //uri sended by Microsoft plateform $notif=new WindowsPhonePushNotification($uri); $notif->push_toast("123","456"); notif_url = $notif_url; } /** * Toast notifications are system-wide notifications that do not disrupt the user workflow or require intervention to resolve. They are displayed at the top of the screen for ten seconds before disappearing. If the toast notification is tapped, the application that sent the toast notification will launch. A toast notification can be dismissed with a flick. * Two text elements of a toast notification can be updated: * Title. A bolded string that displays immediately after the application icon. * Sub-title. A non-bolded string that displays immediately after the Title. */ public function push_toast($title, $subtitle,$delay = WindowsPhonePushDelay::Immediate, $message_id=NULL) { $msg = "" . "" . "" . "".htmlspecialchars($title)."" . "".htmlspecialchars($subtitle)."" . "" . ""; return $this->push('toast',$delay+2,$message_id, $msg); } /** *A Tile displays in the Start screen if the end user has pinned it. Three elements of the Tile can be updated: *@background_url : You can use a local resource or remote resource for the background image of a Tile. *@title : The Title must fit a single line of text and should not be wider than the actual Tile. If this value is not set, the already-existing Title will display in the Tile. *@count. an integer value from 1 to 99. If not set in the push notification or set to any other integer value, the current Count value will continue to display. */ public function push_tile($background_url, $title, $count, $delay = WindowsPhonePushDelay::Immediate,$message_id=NULL) { $msg = "" . "" . "" . "".htmlspecialchars($background_url)."" . "$count" . "".htmlspecialchars($title)."" . "" . ""; return $this->push('token',$delay+1, $message_id,$msg); } /** * If you do not wish to update the Tile or send a toast notification, you can instead send raw information to your application using a raw notification. If your application is not currently running, the raw notification is discarded on the Microsoft Push Notification Service and is not delivered to the device. The payload of a raw notification has a maximum size of 1 KB. */ public function push_raw($data, $delay = WindowsPhonePushDelay::Immediate,$message_id=NULL) { return $this->push(NULL,$delay+3,$message_id, $data); } /** *@target : type of notification *@delay : immediate, in 450sec or in 900sec *@message_id : The optional custom header X-MessageID uniquely identifies a notification message. If it is present, the same value is returned in the notification response. It must be a string that contains a UUID */ private function push($target,$delay,$message_id,$msg) { $sendedheaders= array( 'Content-Type: text/xml', 'Accept: application/*', "X-NotificationClass: $delay" ); if($message_id!=NULL) $sendedheaders[]="X-MessageID: $message_id"; if($target!=NULL) $sendedheaders[]="X-WindowsPhone-Target:$target"; $req = curl_init(); curl_setopt($req, CURLOPT_HEADER, true); curl_setopt($req, CURLOPT_HTTPHEADER,$sendedheaders); curl_setopt($req, CURLOPT_POST, true); curl_setopt($req, CURLOPT_POSTFIELDS, $msg); curl_setopt($req, CURLOPT_URL, $this->notif_url); curl_setopt($req, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($req); curl_close($req); $result=array(); foreach(explode("\n",$response) as $line) { $tab=explode(":",$line,2); if(count($tab)==2) $result[$tab[0]]=trim($tab[1]); } return $result; } } ?>

2012年3月20日 星期二

Mobile devices screen size

jquery zoom 解決不同 mobile devices 的 screen 問題

$( document ).ready( function() {
var $body = $('body'); //Cache this for performance

var setBodyScale = function() {
var scaleSource = $body.width(),
scaleFactor = 0.35,
maxScale = 600,
minScale = 30; //Tweak these values to taste

var fontSize = scaleSource * scaleFactor; //Multiply the width of the body by the scaling factor:

if (fontSize > maxScale) fontSize = maxScale;
if (fontSize < minScale) fontSize = minScale; //Enforce the minimum and maximums

$('body').css('font-size', fontSize + '%');
}

$(window).resize(function(){
setBodyScale();
});

//Fire it when the page first loads:
setBodyScale();
});



var designWidth = 480; // zoom to fit this ratio
var designHeight = 762; // not 800 b/c top bar is 38 pixels tall
var scaleChange = 1; // % change in scale from above #s

function zoomScreen() {
var docWidth = window.outerWidth;
var docHeight = window.outerHeight;

if (docWidth != designWidth) {
var scaleX = docWidth / designWidth;
var scaleY = docHeight / designHeight;
if (scaleX < scaleY) {
$('body').css('zoom', scaleX);
scaleChange = scaleX;
} else {
$('body').css('zoom', scaleY);
scaleChange = scaleY;
}
}
}

2011年5月13日 星期五

iPhone Apps 被 reject



 一心想把八字緣繼續發展成有緣人,點知這次被 reject 了。或許因為收費的 apps, Apple 公司要確保質素吧。另一原因或者他以為排八字的 program 是拿別人的 (正如下面的回覆 ...content aggregators, or a collection of links...)所以 reject.  雖然整個程式是 100% 自行開發的,但這也難證明。所以繼續再來變成 standalone 版 再加入同年月日生人的 database。這樣應該可以了。


Hello KAM SHING NG,
Thank you for submitting 有緣人 to the App Store.
We've completed the review of your app, but cannot post this version to the App Store because it did not comply with the App Store Review Guidelines, as detailed below:
  • 12.3: Apps that are simply web clippings, content aggregators, or a collection of links, may be rejected
To reply to this message or to get more information, visit the Resolution Center in iTunes Connect. Do not reply directly to this email.
Regards,
App Review

2011年5月4日 星期三

八字緣

另一新的 apps














Description

想知道自己每小時的運程指數如何?

想知道自己的貴人是誰?
想知道自己的五行屬性嗎?

.........

這一切的一切,都能通過這個軟體得到答案。

八字乃中國人的智慧結晶,憑著天干地支的組合,審察人生的禍福休咎;這個小工具不單止助你排出八字,給出簡單的描述如五行數量,更會透過每個時辰與八字的關係,提供當日的開心指數作為指標。

八字緣軟件簡介 :

1. 基本功能為八字起盤程式
2. 附設每天開心指數




MySQL Cannot start service

遇到以上問題可這樣解決:

安裝時
1) Multifunctional Database
2) Transactional Database Only
3) No-Transactional Database Only <-----選這個 就 ok 或把 my.ini default-storage-engine=INNODB ->> default-storage-engine=MYSIM
搞了半小時才解決...激死

iOS Apps Submission Quick Guide

iphone app submission 是個挺煩的過程,網上找到些 quick guide (http://www.edumobile.org/iphone/iphone-programming-tutorials/submitting-iphone-apps-to-the-apple-app-store-a-step-by-step-guide/)。

Submitting iPhone Apps To The Apple App Store – A Step by Step Guide
On September 13, 2010, in iPhone Programming Tutorials, by vishy

Here’s a quick step by step guideline that you can print and keep hand, to use when your app is ready for submission. I am assuming that the reader of this article has an iPhone Developer License.

Here’s a quick step by step guideline that you can print and keep hand, to use when your app is ready for submission. I am assuming that the reader of this article has an iPhone Developer License.

====== Step 1 ======

Certificate is an essential element to submit or test an application on iphone. It comes with code sign(Signatures) which would verified when an application is submitted on apple store or when tested on iphone.

One can bypass these if an application is installed on jail-break iphone or when submitted on Cydia but this is not possible when one wants submit it to Appstore.

One has to through 2 step procedure to create a certificate from developer portal. I simply copied those two from “iphone developer portal”

[1] Generating Certificate Signing Request

[2] Submitting a Certificate Signing Request for Approval

Generating a Certificate Signing Request:

[3] Open the Utilities folder and launch Keychain Access from the Applications folder.

[4] Set the value of Online Certificate Status Protocol (OCSP) and Certificate Revocation List (CRL) to “off” in the Preferences Menu.

[5] Select Keychain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority.

[6] Fill in your email address in User Email Address Field. Confirm that this email address is same as provided at the time of registering as iPhone developer.

[7] Fill in your name in the Common Name field. Confirm that this name is same as provided at the time of registering as iPhone developer.

[8] It is not necessary to have an Certificate Authority (CA). The ‘Required’ message would be eliminated after finishing the following step.

[9] Click the ‘save to disk’ radio button if prompted, choose ‘Let me specify key pair information’ and proceed.

[10] If you choose ‘Let me specify key pair’ option then one has provide a file name and click ‘Save’. Select ‘2048 bits’ for Key Size and ‘RSA’ for the algorithm in next screen and proceed.

[11] CSR file would created on the desktop by Certificate Authority.

Submitting a Certificate Signing Request for Approval:

[1] Once CSR file is created log in to the iPhone developer program portal and go to ‘Certificates’> ‘Development’ and select ‘Add Certificate’.

[2] Click the ‘Choose file’ button, select your CSR and click ‘Submit’. The portal will reject the CSR if Key Size is not set to 2048 bit at the time of CSR creation.

[3] This will followed by notification to Team Admins by email of the certificate request.

[4] The change in the certificate status would informed by email on approval or rejection of the CSR by Team Admin.

Download/Installing Certificate on your machine

[5] Once the CSR is approved the Team Members and Team Admins can download their certificates via the ‘Certification’ section of the Program Portal. Choose ‘Download’ next to the certificate name to download your iPhone development certificate to your local machine.

[6] Once this is done double-click the .cer file to launch Keychain Access and install your certificate.

On installation of certificate on your MAC the next step is to create an App ID.

Note: You have to follow this step only once and late you don’t have to make certificates for your other applications.

====== Step 2 ======

Follow the following steps to create an App ID:

[1] Go to ‘App IDs’ and click ‘App ID’ after logging in to iPhone developer program portal.

[2] Populate the ‘App Id Name’ field with your application name (that is – iPhone app) and in ‘App Id’ enter something like com.yourdomain.applicationname (i.e com.edumobile.iphoneapp) and click submit.

[3] Please do note down the “App Id” as this would be utilized in Info.plist, bundle identifier tag.

====== Step 3 ======

Next step would be to create a Provisioning file for our Xcode and is the last step for creating binary which would submit it to Appstore.

[1] After you navigate to ‘Provisioning’> ‘Distribution’ click ‘Add Profile’ in iphone developer program portal.

[2] Choose “App Store” in “Distribution Method”.

[3] In “Profile Name” enter your application name (i.e iphoneapp) which will be your provisioning profile name as well.

[4] In “App ID” select the app name(i.e. iphoneapp) which you created in Step 2.

[5] After downloading the Provisioning profile copy it to your/YourUserName/Library/MobileDevice/Provisioning Profile.

====== Step 4 ======

Now everything is step up, open your project in Xcode

[1] Click “i” Info button after selecting your project from “Group & File” in left side bar.

[2] Navigate to “Configuration” tab and select “Release”. Click the “Duplicate” button from bottom, name is “iphoneDistribution”.

[3] Click on “Build” tab and choose “iphoneDistribution” and enter in “Search in Build Settings” filed ‘Base SDK’ and select the current selected Device and change to what gadget your application is targeting (I prefer “Device-iPhone OS 2.0)

[4] Now in “Search in build setting” field enter “code signing identity” and choose the provisioning profile created earlier in Step 3. Apply the same to the child property “Any iPhone OS Device”.

[5] Once this done close the Info screen and select the “Target”> “Your App” from “Group & File” in left side bar and click on “Info” button again from Xcode.

[6] To be on the safer side repeat step 3 and 4.

[7] With the Info screen still open click on “Properties” tab and enter “App Id”(i.e. com.edumobile.iphoneapp) in Identifier field.

[8] Now that all is done, click on “Build” (cmd+B) from Xcode>Build.

[9] You will find your binary file created on right clicking on “Product”> “YourApp” and selecting “Reveal in Finder”. Zip this file.

====== Step 5 ======

The next step is to submit the binary file created to itunesconnect.

[1] In your browser type https://itunesconnect.apple.com/ (this website is very slow over https) and login using your iPhone developer account.

[2] Click on “Manage Your Account” > “Add Application”

[3] On replying to a simple question from apple you can sumbit your application to app store. You also need few things in your system before you submit your application.

a) Application Name (must be unique)

b) Application description

c) Application Category

d) URL for your application feedback.

e) Icon of your application in 512 x 512 size.

f) Main picture of your application in 320 x 480 or 320 x 460 size. (You have option to submit up to 4 more pictures of your application).

2011年5月3日 星期二

Programming

剛剛 approved 的 iphone apps










預測小孩的高度。以最新的大學科研成果作為計算方法。


A scientific kids height predictor based on the lastest research.
Simply enter both of the parents height and it will predict your kids height.