cancel
Showing results for 
Search instead for 
Did you mean: 

Adapter class in Agentry Android Client Solution not working.

Former Member
0 Kudos

Hello Experts,

Bill Froelich

Pratik Chavan

I want to call google map on agentry client for that I generate one new class i.e. ZDisplay and extend it by ExternalDataDisplayAdapter.

Here is my Code :

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

import android.content.Context;

import android.view.View;

import android.webkit.WebView;

import android.widget.LinearLayout;

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

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

public class ZDisplay extends ExternalDataDisplayAdapter {

    ExternalDataDisplayModel _model;

    Context _context;

    @Override

    public void initialize(ExternalDataDisplayModel model, Context context) {

        // TODO Auto-generated method stub

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

        _model = model;

        _context = context;

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

    }

    @Override

    public View getView() {

        System.out.println("In 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/");

            // WebView browser = null;

            // browser.loadUrl("https://www.google.co.in/");

        }

        return webview;

    }

}

     

   Also I add my class name in Agentry and take External field as a value. But I got blank screen even don't get print statements in logcat.also I add Toast there but nothing display on screen.I think that the control not get into my class that's why not a single print statement couldn't display.

But why I cant get the error so I am unable to findout the solution.Is there anyone face the same issue or have the solution for the same.

Regards

Prajakta

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Really thanks for your reply these are very helpful for me.I got the solution for that as per the below screen shot.

Thanks and Regards

Prajakta

Answers (1)

Answers (1)

Former Member
0 Kudos

hello Prajakta

add this code in your class :

public View getView() {

  // TODO Auto-generated method stub

  LayoutParams params = new LayoutParams(1000, 1000);

  FrameLayout frame = new FrameLayout(_context);

  frame.setLayoutParams(params);

  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;

  }

Regards,

Hitesh

Former Member
0 Kudos

Hello Hitesh,

I tried your code but still my problem is as it is, that control can not get into my class.

In agentry side I do this,

I create simply one field and in external field added class name of our adapter class, is it sufficient to call our class.or any other things have to be add to detect adapter class.

Thanks & Regards

Prajakta

Former Member
0 Kudos

hello Prajakta

use the External Data edit type in agentry side as you have extended the ExternalDataDisplayAdapter class.

Regards,

Hitesh

Former Member
0 Kudos

hello Hitesh,

Thanks for your reply.

I have one question that to display any URL, is this adapter class and edit type is correct?

or we are missing something.

and also having one doubt that I am using sysout and toast in initialize method but why they are not coming.

Regards

Prajakta

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

The class type simply links the type of data being exposed from Agentry.  ONce the Open UI code is invoked you can display anything you want.

For example, the ESRI Open UI control extends from a List View control so that the collection of obejcts is exposed through Open UI in one case and uses a extends from String field in another case.  Both classes display an ESRI map on the device but start with different Agentry field types.

You could just as easily extend from a String field where the contents of the string is the URL you want to display in the Open UI control.

--Bill

Former Member
0 Kudos

Hello Hitesh,


I tried with the External Data edit type, but it is agentry Browse button and not opening the google page as URL given in getView method of OpenUI.



Hello Bill,


I tried with the String edit type but it is not invoking the adapter class and the screen on device is coming with gray color.



Regards,

Prajakta

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Prajakta,

Have you tried this with the sample controls / project to verify your code is compiling the classes in correctly?

--Bill

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

I tested using the StringDisplayAdapter and the following code.  It works as expected in my Agentry project.

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