Tizen Mobile 2.3 WebViewer Example

你说的曾经没有我的故事 提交于 2019-12-11 10:53:44

问题


Is there any example projects for tizen 2.3 for implementing webview in your app. This is not in the samples with official sdk.


回答1:


Here is an example that you can refer

#include <stdio.h>
#include <stdlib.h>

#include <EWebKit2.h>
#include <Eina.h>

#include <Ecore.h>
#include <Ecore_Evas.h>

#define W_WIDTH (480)
#define W_HEIGHT (800)
#define W_TEXTAREA_X (0)
#define W_TEXTAREA_Y (416)
#define W_TEXTAREA_WIDTH (W_WIDTH)
#define W_TEXTAREA_HEIGHT (64)
#define W_MAP_ORIGINE_X (0)
#define W_MAP_ORIGINE_Y (480)
#define W_MAP_HEIGHT (480)

static Ecore_Evas *window;
static Evas *e_webview;
static Evas *e_rect;
static Evas_Object *browser;
static Evas_Object *text;

static const char *default_url = "http://www.paytm.com";

int main(int argc, char *argv[]) {

    int x = 0, y = 0, width = 0, height = 0;
    char buf[256];

    memset(buf, '\0', sizeof(buf));

    ecore_evas_init();

    window = ecore_evas_new(NULL, 0, 0, W_WIDTH, W_HEIGHT, "frame=0");
    if(!window)
    {
        printf("ecore_evas_new error\n");
        return 0;
    }

    // get screen size
    ecore_evas_screen_geometry_get(window, &x, &y, &width, &height);

    // Don't comment elm_init, SIGSEGV is occurred.
    elm_init(argc, argv);

    ecore_evas_size_min_set(window, 480, 800);
    ecore_evas_size_max_set(window, width, height);

    ecore_evas_show(window);

    // test rectangle
    e_rect = ecore_evas_get(window);
    text = evas_object_text_add(e_rect);
    evas_object_color_set(text, 256, 256, 0, 255);
    evas_object_move(text, W_TEXTAREA_X, W_TEXTAREA_Y);
    evas_object_resize(text, W_TEXTAREA_WIDTH, W_TEXTAREA_HEIGHT);
    evas_object_text_font_set(text, "Sans", 24);
    evas_object_show(text);
    evas_object_layer_set(text, 30);
    evas_object_text_text_set(text, buf);

    // test map
    e_webview = ecore_evas_get(window);
    browser = ewk_view_add(e_webview);
    evas_object_move(browser, W_MAP_ORIGINE_X, W_MAP_ORIGINE_Y);
    evas_object_resize(browser, W_WIDTH, W_MAP_HEIGHT);
    evas_object_show(browser);
    ewk_view_uri_set(browser, default_url);
    evas_object_layer_set(browser, 30);

    ecore_main_loop_begin();

    ecore_evas_free(window);

    ecore_evas_shutdown();

    return 0;
}

This example is modified version of the sample present here https://bugs.tizen.org/jira/secure/attachment/11555/Sample.c



来源:https://stackoverflow.com/questions/30388759/tizen-mobile-2-3-webviewer-example

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!