CCGLSurfaceView Error - android

I'm developing some sample code.
I had some problem using cocos2d.
That is the CCGLSurfaceView problem.
Firstly, I imported cocos2d.jar in my project with fps_images.png file.
And i modify my project for using the cocos2d library.
Here are the code.
public class ToadActivity extends Activity {
protected CCGLSurfaceView _glSurfaceView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_glSurfaceView = new CCGLSurfaceView(this);
setContentView(_glSurfaceView);
}
#Override
public void onStart()
{
super.onStart();
CCDirector.sharedDirector().attachInView(_glSurfaceView);
CCDirector.sharedDirector().setDisplayFPS(true);
CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
}
}
==>>> _glSurfaceView = new CCGLSurfaceView(this);
Here, My application found a error. And at the result, it is killed in my android simulator.
What's the problem?

That library are decreated, not update more. It will be better start using: http://www.cocos2d-x.org/. It use c++, to work on android, use JNI (Native code). Code can be ported to other plataforms, like IOs.
Hope it help!

Related

Trying to Embed Cordova app into Native Android

When I try to follow the guide of Cordova to embed it into a native android application I can't build.
I use this guide:
https://cordova.apache.org/docs/en/latest/guide/platforms/android/webview.html
When I put everything in my main activity I receive an error on config.
It says can't resolve symbol 'config'. I have no clue what I am doing wrong or how to solve it.
onCreate
/* Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cwv = (CordovaWebView) findViewById(R.id.tutorialView);
config.init(this);
cwv.loadUrl(config.getStartUrl());
}

Hide/remove status bar from android source code (Android 6.0.1)

I'm new to this forum, and first of all, i apologize for my English,
I have a question about Android 6.0.1,
I'm customizing the operating system with the source codes for the IMX6 board.
It's possible to remove or hide the "status bar" (notification bar) on the top of the operating system by editing the build.prop file or others files?
Thank you in advance,
public class WelcomeActivity extends AppCompatActivity{
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
}
}
write this code in activity's onCreate method
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setContentView(R.layout.activity_splash);
}

requestWindowFeature(Window.FEATURE_NO_TITLE) ERROR

I'm having trouble putting my application fullscreen in Android Lollipop, my code :
public class AoA extends ActionBarActivity {
protected void oncreate(Bundle savedInstanceState) {
super.onCreate(SavedInstanceState);
setupParameters();
}
public void setupParameters() {
GameParameterSingleton.ORIENTATION = GameParameterSingleton.PORTRAIT;
GameParameterSingleton.SCREEN_HEIGHT= getWindowManager().getDefaultDisplay().getHeight();
GameParameterSingleton.SCREEN_WIDTH = getWindowManager().getDefaultDisplay().getWidth();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
The application works when I do not use fullscreen,
Can anyone help me as I leave fulllscreen ? as I take the title of the application?
It seems that in API 21
this.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
Doesn't work .
Try to Add this to your AndroidManifest.xml file
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Or add this
this.getActionBar().hide();
in onCreate method after super.onCreate(savedInstanceState);

Can screenshot's be disabled in an android app?

I am curious to know if screenshots can be disabled when running a android app if I were to design one.
You are welcome to use FLAG_SECURE to block screenshots and thumbnails of your activities:
public class FlagSecureTestActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
}
}

Android App with PhoneGap: InvocationTarget Exception by calling addJavascriptInterface

I am using the Android SDK and PhoneGap to create a native Android App. Now I want to use Java methods in the view, calling by JS methods.
In the Main Class I called the "addJavascriptInterface" method to bind a java class with the view.
public class App extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
appView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
super.loadUrl("file:///android_asset/www/index.html");
}
}
The problem is I get an InvocationTarget Exception when the programm executes the line "appView.addJavascript..." and the program crashes on the device.
Any solutions here?
Thanks!
Calling Java methods from JavaScript is exactly what PhoneGap plugins enable. Checkout several examples here
Using addJavascriptInterface before super.init(); can make the application crash.
You should try the following :
public class App extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
appView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
super.loadUrl("file:///android_asset/www/index.html");
}
}

Categories

Resources