Click here to Skip to main content
15,886,806 members
Articles / Mobile Apps / Android

Writing an Android GUI using C++: Part 4 - Activity

Rate me:
Please Sign up or sign in to vote.
4.76/5 (24 votes)
20 Jan 2014CPOL3 min read 101.9K   2.6K   81  
The example given in this article is similar to the previous article, except that it is written with C++.
package com.srplab.examples;

import android.app.Activity;
import android.os.Bundle;

import com.srplab.www.starcore.*;

public class TestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        StarCoreFactoryPath.StarCoreCoreLibraryPath = "/data/data/"+ getPackageName()+"/lib";
        StarCoreFactoryPath.StarCoreShareLibraryPath = "/data/data/"+getPackageName()+"/lib";
        
		final StarCoreFactory starcore= StarCoreFactory.GetFactory();
        StarServiceClass Service=starcore._InitSimple("test","123",0,0);
        StarSrvGroupClass SrvGroup = (StarSrvGroupClass)Service._Get("_ServiceGroup");
        Service._CheckPassword(false);
        
        starcore._RegMsgCallBack_P(new StarMsgCallBackInterface(){

			public Object Invoke(int arg0, int arg1, Object arg2, Object arg3) {
				// TODO Auto-generated method stub
				if( arg0 == starcore._Getint("MSG_VSDISPMSG") || 
					arg0 == starcore._Getint("MSG_VSDISPLUAMSG") || 
					arg0 == starcore._Getint("MSG_DISPMSG") ||
					arg0 == starcore._Getint("MSG_DISPLUAMSG") )
					System.out.println("....."+arg2);  /*--capture information from c */
				return null;
			}        	
        });
        
        Object[] Result = Service._DoFile("", "/data/data/"+ getPackageName()+"/lib/libtest_c.so","");   
        if( Result[0] == (Boolean)false )
        	System.out.println("execute c shared library false");
        else
        	System.out.println("execute c shared library true");
        
        StarObjectClass mainobject = (StarObjectClass)Service._Get("mainobject");
        boolean initresult = mainobject._Callbool("Init", this);
        if( initresult == false )
        	System.out.println("init false..............");
        else
        	System.out.println("init true..............");        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions