cancel
Showing results for 
Search instead for 
Did you mean: 

How to create an SAP Android app in Android Studio?

Former Member
0 Kudos

Hello All,

I want to create an simple SAP app for android, for example to start with I just want to display flight details. I am newbie to this, can you please help me how to achieve this.

I read some blogs and tried below things:

1. Installed android studio and able to create apps and test with emulator

2. Downloaded Eclipse Mars and installed SMP tools from install new software

3. Created new project SMP Odata Implementation Project -but I don't have SMP server

4. I am calling Odata service RMTSAMPLEFLIGHT (for testing I am using SAP ES4 Gateway system)

from here I don't know how to proceed, as I don't have SMP is it possible to create an app?

To make it simple , I want to call SAP Odata service in Android Studio. I searched about calling SAP Odata service from Android, but most of the answers are about calling sap odata service from Eclipse IDE. And I think the way to call SAP Odata service in Eclipse IDE is different from calling it in Android Studio. Also, I am not using SMP to create my mobile application. I found some answers suggest to use Odata4j libraries, but I am not able to understand how to use these libraries to call SAP Odata services. Could you please help me in calling SAP Odata service from Android Studio and how to test using emulator.

Appreciate all your help.

Thanks,

Siri.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Any thoughts ? I appreciate all your help.

Please help me to create simple app using Eclipse (Mars) or android studio consuming Odata service from SAP NWGS, not using SMP.

Thanks again.

Answers (1)

Answers (1)

bhuvneshkumar_gupta
Participant
0 Kudos

Hi,

Follow this great document to enter in sap mobile development.

For Creating Sample project in android studio to use Cloud Gateway service, follow these steps -

1 - create a cordova project and add android platform.

2 - Import project in android studio

3 - copy and paste files from following link -  https://jsfiddle.net/bkg00/8g69n62r/8/

    or from file below.

hope this will help you for start learning.

Former Member
0 Kudos

Hello Bhuvnesh,

Thanks so much for your reply. I am trying to develop Native Android app using SMP 3.0 SDK.

I used this blog  as reference and successfully consuming Odata service from Odata demo system. But when I try to replace it with SAP Demo Gateway system URL https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/, I am unable to get connect to back end system. I searched the blogs and found out that as I am not using MAF resources or user on boarding (no SMP server), need to implement UsernamePasswordProvider class which will be invoked by HttpConversationManager . I wrote the implementation code like below:

public class CredentialsProvider implements UsernamePasswordProvider{

  private static CredentialsProvider instance;

  private LogonCoreContext lgCtx;

  private CredentialsProvider(LogonCoreContext logonContext) {

  lgCtx = logonContext;

  }

  public static CredentialsProvider getInstance(LogonCoreContext logonContext) {

  if (instance == null) {

  instance = new CredentialsProvider(logonContext);

  }

  return instance;

  }

@Override

  public Object onCredentialsNeededForChallenge(IReceiveEvent arg0) {

  try {

  String username = lgCtx.getBackendUser();

  String password = lgCtx.getBackendPassword();

  return new UsernamePasswordToken(username, password);

  } catch (LogonCoreException e) {

  return null;

  }

  }

@Override

  public Object onCredentialsNeededUpfront(ISendEvent arg0) {

  try {

  String username = lgCtx.getBackendUser();

  String password = lgCtx.getBackendPassword();

  return new UsernamePasswordToken(username, password);

  } catch (LogonCoreException e) {

  return null;

  }

  }

when I write the above code LogonCoreContext package is not getting imported.  I am using SMP SDK patch 13. Can you please help me to resolve this. My goal is without using MAF and on-boarding trying to connect Gateway system directly from android?

I just started my first app using SMP SDK and found very good blogs and very helpful to learn. Thanks everyone for great work.

I appreciate all your help on this

Thanks,

Siri.

Former Member
0 Kudos

I am successfully consuming OData service in Android directly from Gateway system !!!

I realized that as I am not using MAF API need not to use LogonCoreContext class, I directly invoked Gateway URL Online Store using HttpConversionManager.

Thanks,

Siri.