Generating A Development Key Hash Android Studio

  
-->

When App Center builds a Xamarin.Android application with a debug build type, a keystore associated with a developer is not required. These builds will be automatically code signed with a debug key. For a release build that will be deployed, App Center will require a keystore to be uploaded.

  1. If you run apps that use Facebook Login, you need to add your Android development key hash to your Facebook developer profile. For the version of your app that you release to you also need to generate and set a Release Key Hash. On either OS X or Windows you can get a key hash by generating it or by using the value returned by Settings.getApplicationSignature(Context).
  2. Apr 16, 2017  How to Get Generate SHA1 MD5 Key Certificate from Android Studio in Windows, Linux, Mac. Start a fresh project in Android Studio or Open your existing project from which you want to get SHA1 MD5 Key.
  3. Jul 12, 2016  You should create a signed build before generating SHA-1 hash value. Create Signed Build. How To Create Signed APK Or Build. The above link will show you how to create signed APK using Android Studio. We need to create keystore file and specify it in signingConfigs for creating a SHA1 key for release variant.

Generating a keystore

If you do not currently have a keystore, you can generate one using instructions specific for the OS and IDE of your choice.

1. In Windows

If you run apps that use Facebook Login, you need to add your Android development key hash to your Facebook developer profile. For the version of your app that you release to you also need to generate and set a Release Key Hash. On either OS X or Windows you can get a key hash by generating it or by using the value returned by Settings. In case, if your app has already been published, you need to add both Android key hash and release key hash for your development. Generating a Development Key Hash. You'll have a unique development key hash for each Android development environment. To generate a development key hash, on Mac, run the following command in terminal.

You can use the instructions for different versions of Visual Studio to generate a keystore. Or, if you want to use the command line, check: 2. Android: Generate a Private Certificate in Cross Platform Development Documentation

2. In macOS

Instructions on generating a keystore to sign APKs can be found in Visual Studio for Mac's official User Guide or in Android Studio's official User Guide.

Setting up Code Signing

App Center currently supports signing only with the uploaded keystore files and credentials. Keystore files have the extension .keystore or .jks. After toggling on 'Sign builds' in the branch configuration, either click the Keystore file box to choose or drag your keystore file into it. Enter the keystore password, the key alias, and the key password to allow App Center to complete the signing of your APK.

  • Android Basics
  • Android - User Interface
  • Android Advanced Concepts
  • Android Useful Examples
  • Android Useful Resources
  • Selected Reading

Android allows your application to connect to facebook and share data or any kind of updates on facebook. This chapter is about integrating facebook into your application.

There are two ways through which you can integrate facebook and share something from your application. These ways are listed below −

  • Facebook SDK
  • Intent Share

Integrating Facebook SDK

This is the first way of connecting with facebook. You have to register your application and then receive some Application Id , and then you have to download the facebook SDK and add it to your project. The steps are listed below:

Generating application signature

You have to generate a key signature, but before you generate it, make sure you have SSL installed, otherwise you have to download SSl. It can be downloaded here.

Now open command prompt and redirect to your java jre folder. Once you reach there, type this command exactly. You have to replace the path in the inverted commas with your keystore path which you can found in eclipse by selecting the window tab and selecting the preferences tab and then selecting the build option under android from left side.

Once you enter it, you will be prompt for password. Give android as the password and then copy the key that is given to you. It is shown in the image below −

Registering your application

Now create a new facebook application at developers.facebook.com/apps and fill all the information. It is shown below −

Now move to the native android app section and fill in your project and class name and paste the hash that you copied in step 1. It is shown below −

If everything works fine, you will receive an application ID with the secret. Just copy the application id and save it somewhere. It is shown in the image below −

Downloading SDK and integrating it

Download facebook sdk here. Import this into eclipse. Once imported, right click on your facebook project and click on properties.Click on android, click on add button and select facebook sdk as the project.Click ok.

Creating facebook login application

Once everything is complete , you can run the samples, that comes with SDK or create your own application. In order to login, you need to call openActiveSession method and implements its callback. Its syntax is given below −

Intent share

Intent share is used to share data between applications. In this strategy, we will not handle the SDK stuff, but let the facebook application handles it. We will simply call the facebook application and pass the data to share. This way, we can share something on facebook.

Android provides intent library to share data between activities and applications. In order to use it as share intent , we have to specify the type of the share intent to ACTION_SEND. Its syntax is given below −

Generating A Development Key Hash Android Studio Free

Next thing you need to is to define the type of data to pass , and then pass the data. Its syntax is given below −

Apart from the these methods, there are other methods available that allows intent handling. They are listed below −

Sr.NoMethod & description
1

addCategory(String category)

This method add a new category to the intent.

2

createChooser(Intent target, CharSequence title)

Convenience function for creating a ACTION_CHOOSER Intent

3

getAction()

This method retrieve the general action to be performed, such as ACTION_VIEW

4

getCategories()

This method return the set of all categories in the intent and the current scaling event

5

putExtra(String name, int value)

This method add extended data to the intent.

6

toString()

This method returns a string containing a concise, human-readable description of this object

Example

Here is an example demonstrating the use of IntentShare to share data on facebook. It creates a basic application that allows you to share some text on facebook.

To experiment with this example, you can run this on an actual device or in an emulator.

StepsDescription
1You will use Android studio to create an Android application under a package com.example.sairamkrishna.myapplication.
2Modify src/MainActivity.java file to add necessary code.
3Modify the res/layout/activity_main to add respective XML components.
4Run the application and choose a running android device and install the application on it and verify the results.

Generate Key Hash Android Studio

Following is the content of the modified main activity file MainActivity.java.

Generating A Development Key Hash Android Studio Software

Following is the modified content of the xml res/layout/activity_main.xml.

Generating A Development Key Hash Android Studio 2

In the below code abc indicates the logo of tutorialspoint.com

Following is the content of AndroidManifest.xml file.

Let's try to run your Application. I assume you have connected your actual Android Mobile device with your computer. To run the app from Android studio, open one of your project's activity files and click Run icon from the toolbar. Before starting your application, Android studio will display following window to select an option where you want to run your Android application.

Generating A Development Key Hash Android Studio Free

Select your mobile device as an option and then check your mobile device which will display your default screen −

Now just tap on the button and you will see a list of share providers.

Now just select facebook from that list and then write any message. It is shown in the image below −