Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Android Development for iOS
Developers
Darryl Bayliss
@Dazindustries
Showing Content (iOS)
- Storyboards
- XIBs
- Code
override func viewDidLoad() {
super.viewDidLoad()
let textLabel = UILabel(frame: CGRectMake(40, 40, 200, 100))
textLabel.t...
Showing Content (Android)
- Navigation Editor Tool
- Layouts
- Code
@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);



LinearLayout linea...
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(anim...
TableViews (iOS)
- Implement the Data Source / Table View
Delegates
- Override the required methods
- Perform your logic
class tableViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet var tableView: UITabl...
RecyclerViews (Android)
- Create a RecyclerView
- Set RecyclerView Layout Manager
- Set RecyclerView Adapter
@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.lay...
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {



public static class ViewHolder ...
User Permissions (iOS)
- Attempt to access a feature at runtime
- Handle the result
class DetailViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func showCame...
User Permissions (Android 6.0)
- Attempt to access a feature at runtime
- Handle the result
public class MainActivity extends Activity {



final int CAMERA_REQUEST_CODE = 0;

Button showCameraButton;



@Override
...
- Android is a mess of disparate OEMs and legacy versions
- Fragmentation is a headache for developers
- Fragmentation pre...
OS Fragmentation
AndroidiOS
Stats from Apple Developer, Android Developer
Device Screen Sizes
AndroidiOS
Screen Sizes (iOS)
- Autolayout
- Setup constraints on views to
accommodate multiple screen sizes
- Use Size Classes for f...
Screen Sizes (Android)
- Views & layouts can be designed to be
pixel independent
- Android resizes layouts based on device...
OS Fragmentation (iOS)
- Encourage users to update for new
features
- Encourage developers to support new
features unavail...
OS Fragmentation (Android)
- Android Support Libraries
- Provides features that are backwards
compatible to devices runnin...
Material Design
- Androids iOS 7 moment
- A visual language based on paper / ink
Material Design
Build Targets / Gradle
Localization
Unit Testing
UI Testing
Extensions / Intents
App Content Searching
Quiz Question #1
• Layout?
• Activity?
• Controller?
What is the Android equivalent of a UIViewController?
Quiz Question #2
• Themes?
• Styles?
• Layouts?
In Android, what are the files that hold your user interface

elements for ...
Quiz Question #3
• onCreate()?
• onAppear()?
• onStart()?
What is Androids equivalent of a viewDidLoad lifecycle call?
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Android development for iOS developers
Upcoming SlideShare
Loading in …5
×

Android development for iOS developers

1,022 views

Published on

iOS Developers need a wide variety of skills and knowledge to perform their jobs well. These skills and knowledge have wide applications beyond iOS, especially when sticking within the realms of Mobile Application Development.

This deck of slides shows some common cases where an iOS Developer can with minimal effort use their existing skills to build Android apps.

Presented at iOSDevUK 2015.

Published in: Software
  • Be the first to comment

Android development for iOS developers

  1. 1. Android Development for iOS Developers Darryl Bayliss @Dazindustries
  2. 2. Showing Content (iOS) - Storyboards - XIBs - Code
  3. 3. override func viewDidLoad() { super.viewDidLoad() let textLabel = UILabel(frame: CGRectMake(40, 40, 200, 100)) textLabel.text = "Super amazing textlabel" self.view.addSubview(textLabel) let button = UIButton(frame: CGRectMake(50, 150, 50, 50)) button.titleLabel?.text = "Super amazing button" self.view.addSubview(textLabel) } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) } override func viewDidDisappear(animated: Bool) { super.viewDidDisappear(animated) }
  4. 4. Showing Content (Android) - Navigation Editor Tool - Layouts - Code
  5. 5. @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 
 LinearLayout linearLayout = new LinearLayout(this);
 
 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
 LinearLayout.LayoutParams.MATCH_PARENT,
 LinearLayout.LayoutParams.MATCH_PARENT);
 
 TextView textView = new TextView(this);
 textView.setText("Super amazing TextView");
 linearLayout.addView(textView); 
 Button button = new Button(this);
 button.setText("Super amazing Button");
 linearLayout.addView(button);
 
 setContentView(linearLayout, layoutParams);
 }
 
 @Override
 protected void onStart() {
 super.onStart();
 }
 
 @Override
 protected void onPause() {
 super.onPause();
 }
  6. 6. override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) } override func viewDidDisappear(animated: Bool) { super.viewDidDisappear(animated) } @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 }
 
 @Override
 protected void onStart() {
 super.onStart();
 }
 
 @Override
 protected void onPause() {
 super.onPause();
 } View Controller Lifecycles
  7. 7. TableViews (iOS) - Implement the Data Source / Table View Delegates - Override the required methods - Perform your logic
  8. 8. class tableViewController : UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self tableView.delegate = self } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 10 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = UITableViewCell(style: UITableViewCellStyle.Value2, reuseIdentifier: nil) cell.textLabel?.text = "Super amazing cell text" return cell } }
  9. 9. RecyclerViews (Android) - Create a RecyclerView - Set RecyclerView Layout Manager - Set RecyclerView Adapter
  10. 10. @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
 
 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
 recyclerView.setLayoutManager(linearLayoutManager);
 
 recyclerView.setAdapter(new RecyclerAdapter());
 }
  11. 11. public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {
 
 public static class ViewHolder extends RecyclerView.ViewHolder {
 
 public TextView textView;
 public ViewHolder(TextView textView) {
 super(textView);
 textView = textView;
 }
 }
 
 @Override
 public RecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
 
 TextView v = (TextView) LayoutInflater.from(parent.getContext())
 .inflate(R.layout.recycler_item_textview, parent, false);
 
 RecyclerAdapter.ViewHolder vh = new RecyclerAdapter.ViewHolder(v);
 return vh;
 }
 
 @Override
 public void onBindViewHolder(ViewHolder viewHolder, int i) {
 viewHolder.textView.setText("Super amazing textview");
 }
 
 @Override
 public int getItemCount() {
 return 10;
 }
  12. 12. User Permissions (iOS) - Attempt to access a feature at runtime - Handle the result
  13. 13. class DetailViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } @IBAction func showCamera(sender: UIButton) { AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { granted in if(granted) { // Do camera stuff here } else { // Handle user rejection } }) } }
  14. 14. User Permissions (Android 6.0) - Attempt to access a feature at runtime - Handle the result
  15. 15. public class MainActivity extends Activity {
 
 final int CAMERA_REQUEST_CODE = 0;
 Button showCameraButton;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main); 
 showCameraButton = (Button) findViewById(R.id.show_camera_button);
 showCameraButton.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {
 showCamera();
 }
 });
 }
 
 public void showCamera() {
 
 if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
 requestPermissions(new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CODE);
 
 } else {
 // ... Show camera
 }
 } @Override
 public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { 
 if (requestCode == CAMERA_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
 // ... Show Camera
 }
 } }
  16. 16. - Android is a mess of disparate OEMs and legacy versions - Fragmentation is a headache for developers - Fragmentation presents a lot of problems for enterprise… there aren’t many good solutions The Internet Said… Quotes from The Next Web, Open Signal & Tech Target
  17. 17. OS Fragmentation AndroidiOS Stats from Apple Developer, Android Developer
  18. 18. Device Screen Sizes AndroidiOS
  19. 19. Screen Sizes (iOS) - Autolayout - Setup constraints on views to accommodate multiple screen sizes - Use Size Classes for fine grained constraint control
  20. 20. Screen Sizes (Android) - Views & layouts can be designed to be pixel independent - Android resizes layouts based on device screen - Can design multiple variants of the same layout for specific device dimensions
  21. 21. OS Fragmentation (iOS) - Encourage users to update for new features - Encourage developers to support new features unavailable on older iOS versions - Runtime detection of OS version in code using Availability attributes
  22. 22. OS Fragmentation (Android) - Android Support Libraries - Provides features that are backwards compatible to devices running old versions of Android - Ability to support devices running Android 1.6 (Donut)
  23. 23. Material Design - Androids iOS 7 moment - A visual language based on paper / ink
  24. 24. Material Design
  25. 25. Build Targets / Gradle Localization Unit Testing UI Testing Extensions / Intents App Content Searching
  26. 26. Quiz Question #1 • Layout? • Activity? • Controller? What is the Android equivalent of a UIViewController?
  27. 27. Quiz Question #2 • Themes? • Styles? • Layouts? In Android, what are the files that hold your user interface
 elements for each screen called?
  28. 28. Quiz Question #3 • onCreate()? • onAppear()? • onStart()? What is Androids equivalent of a viewDidLoad lifecycle call?

×