Wednesday, 6 November 2013

Thursday, 24 October 2013

Wednesday, 25 September 2013

Wednesday, 18 September 2013

Monday, 16 September 2013

substring trong objective-c

Substring trong objective-c dùng để cắt chuỗi con với chiều dài l và bắt đầu từ vị trí thứ i

example:

[@"đây là string" substringWithRange:NSMakeRange(0, 1)]

0 là vị trí bắt đầu
1 là độ dài
Read More

Replace String ( NSString ) trong Objective-C

Replace String  ( NSString ) trong Objective-C dùng để làm việc khi bạn muốn thay thế những ký tự bất kỳ trong chuỗi thành những ký tự do bạn chỉ định.


NSString *str = @" Đây là string ";

str = [str stringByReplacingOccurrencesOfString:@"string"
                                     withString:@"sờ trinh"];

Read More

Saturday, 14 September 2013

Objective - C Protocols là gì và sử dụng như nào?

Nếu bạn đã học qua ngôn ngữ java thì Protocols trong Object tương ứng với interface trong Java


Ví dụ:

// Khởi tạo Protocols

@protocols MyProtocols
- (void)clickMouse;

@end

// What:
// Thế Protocols là gì: Protocols là giao diện, tương đồng với khái niệm giao diện trong Java( Interface )& C#.
// Bản thân Protocols không có sự thực thi, nếu lớp nào cam kết thực thi thì trong phần thực thi implement các phương thức mà Protocols khai báo.
// Why:
// Khai báo method mà các class khác dự định sẽ thực thi
// Khai báo interface cho một object và che dấu nội dung trong nó
// Dễ dàng nắm bắt được cấu trúc nhiều class tương đồng có liên quan
// How
// Khởi tạo MyClass.h

#import
#import MyProtocols;

@interface MyClass{


@end

// Khởi tạo MyClass.m

#import "MyClass.h"
#import

@implemention MyClass{

- (void)clickMouse{

}
}
@end
Read More

Categories trong Objective - C

Categories là một khái niệm mới khi lập trình với Objective - C,
Categories là gì và dùng như nào? xin mời xem tiếp dưới bài:


// Đặt vấn đề:  Khi ta muốn thêm một số phương thức vào một lớp có sẵn ta sẽ có 2 cách

-- Viết lại mã nguồn
-- Dùng Category mở rộng lớp mà không cần phải viết lại mã nguồn của lớp cũ, Category cho phép ta mở rộng lớp cũ trong một bộ thực thi khác.

// dùng categories như nào:

Example:

//  B1: Tạo Class MyClass như sau

MyClass.h

@interface MyClass
- (void) print;
@end


MyClass.m

#import "MyClass.h"
@implemention MyClass
- (void) print{
NSLog(@"Đây là Print");
}
@end


// B2: Muốn thêm một phương thức "println" ta sử dụng tính năng của Category

MyCategory.h

#import "MyClass.h"
@interface MyCategory( MyNewCategory )
- (void) println;
@end

MyCategory.m

#improt "MyCategory.h"
@implemention MyCategory()d
-(void) println{
NSLog( @" Đây là Println " );
}
@end


// B3: Sử dụng Class đã tạo

Main.m

#import "MyCategory.h"
#import "MyClass"

int main( int argc, char *argv ){

MyClass *myObject = [ [  Myclass alloc  ] init  ] ;
[ myObject print ];
[ myObject println ];

}


int main ( int argc, char *argv )  {

NSLog(@" HelloWord");
}
Read More

Friday, 13 September 2013

Objective - C là gì, làm quen với Objective - C

GIỚI THIỆU OBJECTIVE - C

Objective - C  là một ngôn ngữ lập trình hướng đối tượng dùng để lập trình ứng dụng cho nền tảng Mac os, và các máy smartphone như iPhone, iPad.

Là một phần bổ xung cho ngôn ngữ ANSI C dựa trên smalltalk ( ngôn ngữ lập trình hướng đối tượng ). Objective - C mạng lại cho C đầy đủ khả năng lập trình hướng đối tượng một cách đơn giản và dễ hiểu.

Một đoạn mã Objective - C đơn giản:

        int main ( int argc, char *argv )  {
                NSLog(@" HelloWord");
        }

Read More

Phím tắt trong XCode

TỔNG HỢP PHÍM TẮT TRONG XCODE

XCode đã được tạo ra thực sự tiện dụng với những phím tắt, bất kỳ ai lập trình cũng đều quan tâm tới những phím tắt trong Xcode để cải thiện quy trình làm việc một cách nhanh chóng.


Bạn có thể tại file pdf tại đây: https://docs.google.com/file/d/0B-kX0bpMoUDHOVhCX3BWTkEwUjg/edit




Read More

Thursday, 22 August 2013

Here, there and everywhere: Google Keep reminds you at the right time

Notes are a good way to keep track of all you have to do, but most of us need a little nudge now and then. Google Keep can remind you of important tasks and errands at just the right time and place. For example, Keep works with Google Now to remind you of your grocery list when you walk into your favorite grocery store, and nudges you on Thursday night to take out the trash.

To get started, select the “Remind me” button from the bottom of any note and choose the type of reminder you want to add. You can add time-based reminders for a specific date and time, or a more general time of day, like tomorrow morning. Adding a location reminder is incredibly easy too—as soon as you start typing Google Keep suggests places nearby.


 
Of course, sometimes plans change. If you get a reminder you’re not ready to deal with, simply snooze it to a time or place that’s better for you.



 

It’s now even easier to get to all of your notes using the new navigation drawer, which includes a way to view all of your upcoming reminders in one place. And for people who want more separation between their home and work lives, the drawer also lets you easily switch between your accounts. 


And finally, we've made it easier to add your existing photos to a Google Keep note on Android. When you tap the camera icon you can choose between taking a new photo or adding one you already have from Gallery.

The new update is gradually rolling out in Google Play, and available now on the web at http://drive.google.com/keep and in the Chrome App.
Read More

Wednesday, 21 August 2013

The Beautiful Design Summer 2013 Collection on Google Play

Attention to detail makes an app truly beautiful: transitions are fast and clear, layout and typography are crisp and meaningful, and design touches that delight you in surprising ways are sprinkled throughout. Today, we’re publishing a new Beautiful Design collection on Google Play, which highlights 11 beautiful apps with these kinds of masterfully crafted design details.
The collection, which we’ll refresh with new apps every so often, currently includes:
  • Pattrn (by Lucas Rocha), a beautifully focused app for discovering and sharing unique wallpapers on any size screen device.
  • Pocket (by Read It Later), an article keeper and reader app with a beautiful queue browsing interface and a remarkably comfortable and pleasing reading experience on phones and tablets.
  • Timer (by Opoloo), a timer app with an elegant and deeply satisfying timer-creation interface and simple, beautiful theme choices.
  • Eye in Sky WeatherNY TimesGrand St.PinterestPressExpediaFlipboard and TED… each with delightful design details.
If you’re an Android developer, make sure to play with some of these apps to get a sense for the types of design details that can separate good apps from great ones.
Lastly, remember that this new Beautiful Design collection is just one of a number of unique collections on Google Play that are front and center in the new Google Play Store app client.
Read More

Wednesday, 26 June 2013

How To Resolve Invalid Project Description Error in Eclipse Working on Android Project

Frequently when I import projects from GIT via EGIT in Eclipse I get the error “Invalid Project Description” This bugged the hell out of me.



There are two kinds of places where projects can be located: 
 1) In the “default” location. This means that the project directory is a direct child directory of the workspace directory (aka the platform instance location), and the project directory name matches the project name.

 2) Outside the default location, in a directory that is neither a parent or child of the platform instance location. In this case the directory name does not need to match the project name. To ensure a successful import you have to make sure the directory you are creating inside of your \workspace\ dir matches that of the name defined in the .project file. In my example: \workspace3\warmupdater is the same name that is defined in the .project file. This will yield a successful import without the error “Invalid Project Description” warmupdater com.android.ide.eclipse.adt.ResourceManagerBuilder ... ..
Read More

Sunday, 10 March 2013

Share project game libgdx đơn giản! Down phát chạy luôn ^^!

Xin chào các bạn!

Do công việc dạo này bận túi bụi nên mình không có nhiều thời gian để cày Libgdx cũng như là google  translate TUT cho các bạn vì thế mình quyết định sẽ Share 1 project game nhỏ mà mình đang dự định phát triển.

Project này mình lấy trên mạng về của tác giả ở địa chỉ này http://dustinriley.me/project/angry-masons-the-game/  và channel Youtube hướng dẫn rất đầy đủ ở địa chỉ này http://www.youtube.com/watch?v=WP5qA_kgV6Y anh ý nói rất dễ nghe trôi chảy câu nào ra câu đó mỗi tội là mình éo hiểu j cả :D các bạn có thể bật chức năng CC của youtube mà xem...

Đây là 1 số hình ảnh  ScreenShot của game,


       

Đây là màn hình SplashScreen giới thiệu về game


Menu 

Trong game...




Trong project mình share thì mình cũng chỉ thay đổi 1 chút so với project gốc vì thế có j không hiểu các bạn cứ lên channel Youtube theo địa chỉ http://www.youtube.com/watch?v=WP5qA_kgV6Y hoặc comment ở dưới bài viết hoặc gửi mail về địa chỉ phamquocchinh90@gmail.com hoặc add nick skype mình phamquocchinh90 các bạn có thể spam thoải mái :D

Thân mến chào các bạn!

Còn Project các bạn down tại đây: http://www.mediafire.com/?bcar6hn995dnrwa
mình đã cấu hình sẵn hết rồi chỉ cần down xong import vào eclipse là chiến thôi!


Read More

Wednesday, 6 March 2013

Thursday, 31 January 2013

Kiểm tra kết nối mạng của Android

- Trong android có 2 kiểu kết nối mạng là wifi và 3g or 4g...
- Tôi sẽ viết 1 class để bắt sự kiện on/off mạng...( khi mạng thay đổi trạng thái thì sẽ tự bắt được. bla bla..)
- Bài viết được tham khảo từ http://stackoverflow.com/questions/7094606/android-stop-start-service-depending-on-wifi-state

- Tạo class như sau:

public class NetWatcher extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        //here, check that the network connection is available. If yes, start your service. If not, stop your service.
       ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
       NetworkInfo info = cm.getActiveNetworkInfo();
       if (info != null) {
           if (info.isConnected()) {
               //start service
               Intent intent = new Intent(this, MyService.class);
               startService(intent);
           }
           else {
               //stop service
               Intent intent = new Intent(this, MyService.class);
               stopService(intent);
           }
       }
    }
}
-Trong AndroidManifest bạn thêm mấy dòng sau vào 
 
<receiver android:name="com.example.android.NetWatcher">
     <intent-filter>
          <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
     </intent-filter>
</receiver>
// chú ý đổi tên package trong android:name phù hợp với project của bạn



Read More