i´m trying to add admob ane to my game but i´m getting an error.
My error is this, when i import the class i got and erro in my project with the gotoAndPlay(33);
how can i define into class this gotoAndPlay(33); to stops error.
i´m using this package
package
{
import flash.display.Sprite;
import so.cuo.platform.admob.Admob;
import so.cuo.platform.admob.AdmobPosition;
public class SimpleDemo extends Sprite
{
public function SimpleDemo()
{
super();
var admob:Admob= Admob.getInstance();
if(admob.supportDevice){
admob.setKeys("your banner id ");
admob.showBanner(Admob.BANNER,AdmobPosition.BOTTOM_CENTER);
}
}
}
}
So, i don´t know how to declare this gotoAndPlay(33) event in the class.
Since now thanks to all!
Sounds like somewhere your code is trying to use SimpleDemo like it's a movie clip.
To give SimpleDemo all the powers of a MovieClip, make it extends that class
public class SimpleDemo extends MovieClip
instead of extending Sprite which doesn't have timeline functionality.
Now SimpleDemo will have all the MovieClip Methods, like gotoAndPlay.
If SimpleDemo is set as the class file for your document class (or a library object that has more than one frame or code on a frame), then you MUST extend MovieClip (though for the document class it CAN extend Sprite or DisplayObjectContainer if no timeline code or additional frames are used).
Related
I have created several apps that use the Image object (from the image.dart library).
However today I created one app from scratch (using the Android Studio template) and when I add an Image object it gets imported from painting.dart, and things like Image.memory() don't work anymore.Never had this problem before.
This is the class and the offending member. It could not be simpler.
import 'dart:ui';
class ProdutoDoCardapio {
int codigo;
int codprod;
String descricao;
String descrcurta;
String descrlonga;
int destaque;
String obs;
double preco;
String unidade;
String foto;
int qtde = 0 ;
Image imagedata;
}
So my question is: do I have to configure something in some file I am missing to make flutter (or dart) use the correct library in my context?
I tried
import 'package:image/image.dart';
in the class file, but flutter says this url does not exist, although it is mentioned in many exemples online.
So, any help will be welcome.
Found the solution. I accepted Flutter's suggestion to import dart.ui, but the correct import is
import 'package:flutter/material.dart';
So the problem is solved.
I have provided an aplication made in android that has a navigation drawer and in it has a list of games. I have to create another game and to put it there. The game that has to be created by my must use libGDX but the original application didn't use this library.
Is it possible to do this ? If Yes, how can I add the libgdx to the exiting project. On github I found only how to start a new project with libGDx, an not how to add it to exising code. thanks.
You can achieve this with these 2 steps:
1. Add LibGDX to your project
On your android gradle file: build.gradle (app or android module)
dependencies {
...
// Add this line, it is recommended to use the latest LibGDX version
api "com.badlogicgames.gdx:gdx-backend-android:1.9.10"
}
2. Initialize LibGDX for a view or use a LibGDX managed activity
Option 1: Initialize for a view
Since you have a navigation drawer and more code native to android this option fits your needs better. From this question (How to add LibGDX as a sub view in android):
The AndroidApplication class (which extends activity) has a method named initializeForView(ApplicationListener, AndroidApplicationConfiguration) that will return a View you can add to your layout.
-- Matsemann
Also here's documentation on how to implement this (Fragment based LibGDX).
Option 2: Use a managed activity
This is the default/most common use of LibGDX, you will need to change your code as follows:
Your activity needs to extend Android application:
public class MainActivity extends AndroidApplication {
Create a class extending Game or ApplicationAdapter:
import com.badlogic.gdx.Game;
public class LibGDXGame extends Game {
#Override
public void create() {
System.out.println("Success!");
}
}
Initialize the LibGDX managed activity:
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
public class MainActivity extends AndroidApplication {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new LibGDXGame(), config);
}
}
Generally what you want is possible, I reckon your best bet would be to create a new libgdx project with their GUI and to then manually merge the files that are needed.
I'm working on a phonegap project which contains a canvas overlayed with kinetic.js, which allows a user to pinch zoom and pan around an image, then draw annotations on it. it works spliendidly in a browser and on windows and apple tablets, but of course android is a good bit slower.
as a solution, i've released the app using https://github.com/thedracle/cordova-android-chromeview. after switching my main java class to use ChromeView as the webview, i'm getting this error on startup:
12-03 13:21:09.083: E/chromium(13917): [ERROR:aw_browser_context.cc(191)] Not implemented reached in virtual quota::SpecialStoragePolicy* android_webview::AwBrowserContext::GetSpecialStoragePolicy()
after debugging through the codebase, it looks like the error is triggering here:
private void setNativeContentsClientBridge(int nativeContentsClientBridge) {
mNativeContentsClientBridge = nativeContentsClientBridge;
}
(AwContentsClientBridge.java line 36).
i'm trying to find out what the nativeContentsClientBridge int is. My value is 1611312352 but i haven't a notion of what that represents.
my gut feel is that the chromium browser is missing an implementation for accessing localstorage. i found this bug:
https://github.com/pwnall/chromeview/issues/27
where someone is experiencing the same thing, but there is no solution.
for assistance, this is my main activity class:
package com.companion;
import org.apache.cordova.Config;
import org.apache.cordova.CordovaActivity;
import us.costan.chrome.ChromeSettings;
import us.costan.chrome.ChromeView;
import android.os.Bundle;
public class CompanionApp extends CordovaActivity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
ChromeView chromeView = new ChromeView(CompanionApp.this);
ChromeSettings settings = chromeView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
setContentView(chromeView);
super.loadUrl(Config.getStartUrl());
}
}
Thanks for your help,
Margaret
Don't know if it's normal, but it seems that a method's not implemented in Chromium base code : https://github.com/01org/pa-chromium/blob/master/android_webview/browser/aw_browser_context.cc
Here's that particular method:
quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() {
// TODO(boliu): Implement this so we are not relying on default behavior.
NOTIMPLEMENTED();
return NULL;
}
I hope it helps :)
As the title suggests I am trying to create an Android app using Phonegap and then trying to insert Admob into it.
I am using this tutorial provided by Adobe and it is working fine. After this when I use this tutorial provided by Google I run into problems.
According to the Google tutorial, I have to change the activity class, below is the original and the second block of code is the altered code. There doesn't seem to be any errors preventing it from compiling. It's just when I try and run it using the Android emulator I get an error stating "Unfortunately MyFirstPhonegapPlugin has stopped"
Note, using the Google tutorial, there are two ways of implementing the code, using just the class below and using a mixture of XML and the class below. I tried the other way and due to getting errors which doesn't let me compile, I've gone for this way.
package com.tricedesigns;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
public class MyFirstPhoneGapPluginActivity extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Adjusted code:
package com.tricedesigns;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import com.google.ads.*;
public class MyFirstPhoneGapPluginActivity extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
}
}
I am using Phonegap 1.6.1 and the most up to date SDK for Android and Admob
The way Phonegap is implemented, it pretty much hides all the details about Android and lets you basically implement a mobile web app as a native app. If you care to implement Android natively, I'd recommend reading the Hello World tutorial. The code you have here is crashing on AdView adView = (AdView)this.findViewById(R.id.adView); because you don't have a layout file with an AdView element with id adView.
If you're more interested in the mobile web part of it and plan to continue sticking with Phonegap, your best bet is to try this plugin which lets you make JavaScript calls using the Phonegap framework, and the plugin performs all of the underlying Android calls necessary to get ads.
Here is a fully functional project of what I was looking for
old version phonegap not support extenal jar lib.
but now phonegap add some new feathers.
use phonegap builder ,add config
add some config
<gap:plugin name="com.admob.plugin" version="1.0.0" source="plugins.cordova.io"/>
so not need any java code any more.
just need some js code.
admob.initAdmob("admob banner ID","admob interstitial ID");
admob.showBanner(admob.BannerSize.BANNER,admob.Position.TOP_APP);
this will create and show a admob banner at top of your app.
i am new to android and i want to do a junit testing in android then i followed this code from android site
i am getting many errors
as HelloAndroid cannot be resolved to a type
Multiple markers at this line
- HelloAndroid cannot be resolved to a type
- The constructor ActivityInstrumentationTestCase2(Class) refers to the missing type
HelloAndroid
Multiple markers at this line
- The method getActivity() from the type ActivityInstrumentationTestCase2 refers to the missing type
HelloAndroid
- HelloAndroid cannot be resolved to a type
Multiple markers at this line
- HelloAndroid cannot be resolved to a type
- com.example.helloandroid.R cannot be resolved to a
variable
package com.example.helloandroid.test;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
public class HelloAndroidTest extends ActivityInstrumentationTestCase2<HelloAndroid> {
private HelloAndroid mActivity; // the activity under test
private TextView mView; // the activity's TextView (the only view)
private String resourceString;
public HelloAndroidTest() {
super("com.example.helloandroid", HelloAndroid.class);
}
#Override
protected void setUp() throws Exception {
super.setUp();
mActivity = this.getActivity();
mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview);
resourceString = mActivity.getString(com.example.helloandroid.R.string.hello);
}
public void testPreconditions() {
assertNotNull(mView);
}
public void testText() {
assertEquals(resourceString,(String)mView.getText());
}
}
can anyone help me
Too little space in the comments to show you my point...
One of the things you're missing (seeing your code) is the import section:
Your import section:
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
Tutorials import section:
import com.example.helloandroid.HelloAndroid;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
Also the tutorial says:
This tutorial and its code depend on the Hello World tutorial. If you
haven't completed that tutorial already, do so now. You will learn the
fundamentals of Android application development, and you will have an
Android application that is ready to be tested. The tutorial guides
you through the setup of an Android test project using the ADT Plugin
for Eclipse and other SDK tools. You will need an SDK development
platform that is version 1.5 (API level 3) or higher.
Make sure you have completed this tutorial first. Compare your HelloAndroid class with the final version in the HelloWorld tutorial. Happy coding!
I tried the same example it worked for me
I guess in the code
public HelloAndroidTest() {
super("com.example.helloandroid", HelloAndroid.class);
}
instead of HelloAndroid.class you should put the class name in my case it was MainActivity
I changed it to MainActivity.class and it worked
Check for the class you are testing and change the <HelloAndroid> to the class name i.i MainActivity