cancel
Showing results for 
Search instead for 
Did you mean: 

Android OpenUI Custom Control- getView method has not been called by Agentry

former_member337066
Participant
0 Kudos

Hello Expert,

I have created a ZDisplay class extend with ExternalDataDisplayAdapter class  in Agentry AgentryAndroidClientSolution project within the "com.sap.mobile.platform.client.openui.extensions". I have also created getView method and through method I am passing google ULR. Here is the code

package com.sap.mobile.platform.client.openui.extensions;

import com.sap.mobile.platform.client.openui.adapters.ExternalDataDisplayAdapter;

import com.sap.mobile.platform.client.openui.models.ExternalDataDisplayModel;

import android.content.Context;

import android.view.View;

import android.view.View.OnClickListener;

import android.webkit.WebView;

import android.widget.Button;

import android.widget.LinearLayout;

import android.widget.TextView;

public class ZDisplay extends ExternalDataDisplayAdapter {

  ExternalDataDisplayModel _model;

   Context _context;

  @Override

  public void initialize(ExternalDataDisplayModel model, Context context) {

  // TODO Auto-generated method stub

  _model= model;

   _context= context;

  }

  @Override

  public View getView() {

   WebView webview=null;

 

   if(_context!=null)

   {

   LinearLayout ll = new LinearLayout(_context);

   ll.setOrientation(LinearLayout.VERTICAL);

   webview = new WebView(_context);

 

   webview.loadUrl("http://google.com/");

 

   //browser.loadUrl("URL");

 

   }

   return webview;

  // TODO Auto-generated method stub

  //return null;

  }

}

Then I export AgentryAndroidClientSolution project to create apk.

After that in Agentry, I have created one screen set and in that one Field of Edit Type -"External Field", then in External Field selection I put ZDisplay adapter as Class Name.

But after publishing agentry application in agentry server and running apk in android device I am not able to see google page as I pass as URL in getView method of class ZDisplay in AgentryAndroidClientSolution project.

Here are some screen shot.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Ashish,

I have solution for your Question I am facing same issue.I put my packages in Resources project not in solution.I do this and my adapter class initiates.

Regards

Prajakta

Answers (1)

Answers (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you post a screen shot of your Field Definition properties and External Field properties from the Agentry editor?

Have you considered putting in a popup message (toast) during initialization to verify your code is being called?

--Bill

former_member337066
Participant
0 Kudos

Hello Bill Froelich

I have not put popup message.

Here are the screen shots for Field Definition properties and External Field properties.

Defining Field Edit Type as "External Field"

Here calling ZDisplay class

And we are facing some errors.

06-23 13:07:04.179: E/ActivityThread(3444): Activity com.syclo.agentry.client.android.ui.builtin.ModuleMenuActivity has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@41df5c48 that was originally registered here. Are you missing a call to unregisterReceiver()?

06-23 13:07:04.179: E/ActivityThread(3444): android.app.IntentReceiverLeaked: Activity com.syclo.agentry.client.android.ui.builtin.ModuleMenuActivity has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@41df5c48 that was originally registered here. Are you missing a call to unregisterReceiver()?

06-23 13:07:04.179: E/ActivityThread(3444): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:800)

06-23 13:07:04.179: E/ActivityThread(3444): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:601)

06-23 13:07:04.179: E/ActivityThread(3444): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1650)

06-23 13:07:04.179: E/ActivityThread(3444): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1630)

06-23 13:07:04.179: E/ActivityThread(3444): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1624)

06-23 13:07:04.179: E/ActivityThread(3444): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:430)

06-23 13:07:04.179: E/ActivityThread(3444): at com.immersion.android.haptics.HapticFeedbackManager.setupPackageBroadcastReceiver(HapticFeedbackManager.java:564)

06-23 13:07:04.179: E/ActivityThread(3444): at com.immersion.android.haptics.HapticFeedbackManager.<init>(HapticFeedbackManager.java:108)

06-23 13:07:04.179: E/ActivityThread(3444): at com.immersion.android.HapticFeedbackManagerProxy.initialize(HapticFeedbackManagerProxy.java:90)

06-23 13:07:04.179: E/ActivityThread(3444): at com.immersion.android.HapticFeedbackManagerProxy.access$100(HapticFeedbackManagerProxy.java:30)

06-23 13:07:04.179: E/ActivityThread(3444): at com.immersion.android.HapticFeedbackManagerProxy$1$1.run(HapticFeedbackManagerProxy.java:71)

06-23 13:07:04.179: E/ActivityThread(3444): at java.lang.Thread.run(Thread.java:856)

Regards,

Ashish

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Ashish,

I also see the leaked IntentReceiver messages and just ignore them.

Remember that debugging of your open ui control will be done through the development environment and not the Agentry server.  You don't need to setup for Agentry debugging as that will only affect your server side java steps.

If you want to debug you need to setup your Android development environment for debugging over USB.  Since that is specific to Android there is no SAP documentation about it.  You can google for examples on how to setup for this.

In my initialize I sometimes use a Toast message so I see it popup on my device when the screen loads.

Toast.makeText(_context.getApplicationContext(), "Open UI Initialize", Toast.LENGTH_SHORT).show();

I also add logging that then outputs to the logcat window in eclipse to montior activity.

One other thing, did you mark your src folder under AgentryAndroidClientSolution to be used as a source folder?  If you did it will show like this in Eclipse with the symbol on the folder icon.

To mark it right click on the AgentryAndroidClientSolution > src folder and select Build Path | Use as Source Folder.

--Bill

former_member337066
Participant
0 Kudos

Hi Bill Froelich,

Thanks for describing all the points. We have mark the src folder as Source Folder.

And now I have added the toast code in initialize method. Even we also added

System.out.println("In initialize1");

But still toast message is not coming on device screen and ZDisplay class is not detecting from agentry.

Is Activity class need to be called to detect ZDisplay class. If it is so, then please tell me how to code Activity class to detect ZDisplay class.


Best Regards,

Ashish

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Ashish,

Here is a working sample that I used in my test project.   I merged together some sample code from other posts and tested with the sample app.

package com.sap.mobile.platform.client.openui.extensions;

import com.sap.mobile.platform.client.openui.adapters.StringDisplayAdapter;

import com.sap.mobile.platform.client.openui.models.StringDisplayModel;

import android.app.ActionBar.LayoutParams;

import android.content.Context;

import android.util.Log;

import android.view.View;

import android.webkit.WebView;

import android.webkit.WebViewClient;

import android.widget.FrameLayout;

import android.widget.Toast;

public class ZDisplay extends StringDisplayAdapter {

  StringDisplayModel _model;

  Context _context;

 

  @Override

  public void initialize(StringDisplayModel model, Context context) {

  //Toast.makeText(_context.getApplicationContext(), "Open UI Initialize", Toast.LENGTH_SHORT).show();

  Log.i("ZDisplay","Open UI Initialize");

  _model= model;

  _context= context;

  }

  @Override

  public View getView() {

  //Toast.makeText(_context.getApplicationContext(), "Get View", Toast.LENGTH_SHORT).show();

  Log.i("ZDisplay","Get View");

  Toast.makeText(_context.getApplicationContext(), "getView", Toast.LENGTH_SHORT).show();

 

  LayoutParams params = new LayoutParams(1000, 1000);

  FrameLayout frame = new FrameLayout(_context);

  frame.setLayoutParams(params);

  WebView web = new WebView(_context);

  web.setWebViewClient(new WebViewClient());

  web.setMinimumHeight(1000);

  web.setMinimumWidth(1000);

  web.getSettings().setJavaScriptEnabled(true);

  web.loadUrl("http://maps.google.com/maps?");

  frame.addView(web);

  return frame;

 

  // TODO Auto-generated method stub

  //return null;

  }

  @Override

  public boolean isAgentryDisplayingLabel()

  {

  return true;

  }

}

My Agentry control is as follows

--Bill