I'm thinking of integrating Leadbolt (or Tapjoy) to my Libgdx game. I want to make a store based on the clicked forms. More click - more stuff from the store for the user. I found Leadbolt and Tapjoy. These ad providers are providing direct helps for these stuffs. I have take a look on the Leadbolt integrating guide. I have a problem with it. It needs me to pass a context to the AdController. I don't know if it possible in any way to pass the context for the AdController or not, so I would like to ask you about it, that how can I do, if I can. (I haven't tried it in Libgdx yet, but with the superjumper example had problem too, when I wanted to pass a context for something, and I think because the Libgdx app don't extends an Activity, it will have problems too.)
Here is the sample code from Leadbolt:
AdController myControllerForm = new AdController(this, "MY_LB_ID", new AdListener() {
public void onAdProgress() {}
public void onAdLoaded() {
myControllerForm.hideAd();
}
public void onAdFailed() {
launchMain();
}
public void onAdCompleted() {
myControllerForm.hideAd();
launchMain();
}
public void onAdClosed() {
launchMain();
}
public void onAdClicked() {}
public void onAdAlreadyCompleted() {
launchMain();
}
public void onAdHidden() {
launchMain();
}
});
myControllerForm.setAsynchTask(true);
myControllerForm.loadAd();
}
public void launchMain()
{
finish();
startActivity(new Intent(Splash.this, MainApp.class));
}
}
The class extends Activity, and the methods are in the onCreate() method in this example.
If you have integrated the Leadbolt or Tapjoy to your Libgdx game, then could you please give me a code about how did you do it?
Thanks in advance!
LibGDX actually extends AndroidActivity (by AndroidApplication, which extends AndroidActivity).
If you setup your project correctly, you can access it from "Android starter" project. This is also the only place, where you can play with ads, because "Desktop starter" in no way extends AndroidActivity.
Here's also adMob tutorial, which you may find useful (creating overlaying views).
This is all info I can give you, as I don't know whether you want to display your ads always, reload them as time passes or just hide them after particular events. In such cases, you might want to implement your custom interfaces.
Good luck!
Check out the libGDX tutorial on AdMob: http://code.google.com/p/libgdx/wiki/AdMobInLibgdx
Skip the stuff at the top about setting up AdMob, I think you need the part in the "Control" section which talks about getting events from your generic libGDX code (which has to also run on the desktop) into your Android-specific code (for example to show an ad). The general way is to define your own interface (see the IActivityRequestHandler in the AdMob tutorial), and pass an object that implements that interface into your libGDX code. On the desktop this object would do nothing, and on the Android side you can use all the standard Android code to do the right thing.
Related
I tried implementing react-native-draggable-flatlist to my project, but I'm not able to drag the elements. I am able to "pick them" (They get bigger if I press them), but I can't move them to another position.
I had this problem before and found a working soloution in a GitHub issue, but as it seems, MainActivity.java has changed in some version and I don't know how to correctly upgrade it.
The soloution I found:
When I add the #Override for the ReactActivityDelegate, my App crashes after the build.
I noticed that my MainActivity.java looks a little bit different, it seems like the ActivityDelegate is Managed through a class called MainActivityDelegate which extends ReactActivityDelegate:
public static class MainActivityDelegate extends ReactActivityDelegate {
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
super(activity, mainComponentName);
}
#Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
}
It seems like I have to change something here to achieve the same result, but I don't really know what.
EDIT:
According to the RNGH docs you shouldn't change your MainActivity.java that way anymore and wrap your whole App into a GestureHandlerRootView. Some Libaries like react-native-navigation do this by default (in my case). BEcause of that (I think) my App gets completely grey when I use a GestureHandlerRootView. If I don't addd it myself, so I use the one from neavigaion, I still can't drag the items in my list.
I fixed it by wrapping my screen component in a GestureHandlerRootView
The demand is that saving a video frame in the video call. I have made a demo that take a screenshot through the GLSurfaceView's method "onDrawFrame". But when I use the webrtc, it have its own renderer "VideoRendererGUI" .And then when I want to override it, I find it can't be overrided. the main part code :
vsv = (GLSurfaceView) findViewById(R.id.glviewchild_call);
vsv.setPreserveEGLContextOnPause(true);
vsv.setKeepScreenOn(true);
VideoRendererGui.setView(vsv, new Runnable() {
#Override
public void run() {
init();
}
});
And If you have another way to take a screenshot, you can also share with me.
Thanks a lot!
If you use a SurfaceViewRenderer to display the stream, you can use the solution in this answer to capture a frame on the call.
Basically, using surfaceViewRenderer.AddFrameListener with a class that implements EGLRenderer.FrameListener
I will assume that the SurfaceViewRenderer of the peer you want to take a screenshot of is called remotePeerSurfaceViewRenderer, also I will asume that the button that you will use to take a screenshot is called btnScreenshot
So all what you need to do is as "Webo80" said in the answer above use the FrameListener, the issue is the FrameListener implementation of the webrtc takes only the first frame available once the Listener is attached to the SurfaceViewRenderer, so my approach to do that is by attaching the webrtc implementation of the FrameListsner at the second I need to take a screenshot and remove it once it is taken:
btnScreenshot.setOnClickListener((view)-> {
remotePeerSurfaceViewRenderer.addFrameListsner(new EglRenderer.FrameListener() {
#Override
public void onFrame(Bitmap bitmap) {
runOnUiThread(() -> {
/*
do what ever you want with the bitmap for example
imgView.setImageBitmap(bitmap);
*/
localVideoView.removeFrameListener(this);
});
}
}, 1);
})
Important note:
1. Please don't forget to runOnUiThread as Iam doing
2. Please don't forget to remove the listener inside the button onClick() method
I have tried this solution and it is working more than fine, if you want to make your custom solution you have to completely implement the interface "EglRenderer.FrameListener"
I am sorry to say due to unavailability of canvas and other facilities in Android It's not possible to capture screenshot programatically using WebRTC. One can dodge this situation by animating the app's UI and capturing the screenshot manually , store it at configured location and exchange it with other party.
I am working on android map app in xamarin android. I want to handle the zoom event of map. Can anybody tell me how can I do this in xamarin android using map.SetOnCameraChangeListener ..
Regards
This is a bit late of an answer, but this really helped me. Should have everything you need.
http://pastebin.com/dgdiDk2N
Basically you need to implement the interface:
public class MapTab : Fragment, GoogleMap.IOnCameraChangeListener
Then you can set the listener as such:
map.SetOnCameraChangeListener (this);
And you will also need to add the method OnCameraChange:
public async void OnCameraChange (CameraPosition cameraPos)
{
//Do your things here when the camera updates
}
I've been trying to connect to twitter through android for a while.
I'm currently using this api: http://kenai.com/projects/twitterapime/forums/forum/topics/13327-Twitter-API-ME-1-8-Now-with-OAuth-support
I used their exemple with my keys and everything connects without problem. So no problem with configuration.
But in my project which has exactly the same code I can't make it work.
I believe its related with the creation of a new Intent (also this is where the eclipse is point the error)
Im trying to use a custom layout but I don't know what do I need to change to make this specific Twitter layout to work. On main activity I have a button with this:
public void onClick(View v)
{
startActivity(new Intent(this,Twitter.class));
}
on twitter class
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this.webView = (WebView) findViewById(R.id.webView1);
WebView myWebView = new WebView(this);
setContentView(myWebView);
authenticate();
}
private void authenticate()
{
WebViewOAuthDialogWrapper page = new WebViewOAuthDialogWrapper(webView);
page.setConsumerKey(CONSUMER_KEY);
page.setConsumerSecret(CONSUMER_SECRET);
page.setCallbackUrl(CALLBACK_URL);
page.setOAuthListener(this);
page.login();
}
what requirements/adjustments are needed to make/change to the Twitter activity?
I believe I need to change something in the intent-filter but I don't even understand the work of intents. I've been only making easy layouts.
Note that I also gave internet permissions already.
Looks like i was making 2 mistakes.
First i was trying to use "webView" variable in WebViewOAuthDialogWrapper instead
"myWebView" so it wasn't initialized...
Second looks like i forgot to put the order of which the external libraries were loaded....
So be sure to put external libraries on top in eclipse project.
Lost about 2 days with these problems... oh well
I already asked this question, but got answers that don't work and it counted as "Answered". Maybe someone knows how to design button in Eclipse for an Android app, so it takes you to a website ?Let's say this website.Thanks a lot.
Say u wanna go to google.com
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onOpenWebBrowser(View v)
{
Intent webPageIntent = new Intent(Intent.ACTION_VIEW);
webPageIntent.setData(Uri.parse("https://www.google.co.in/"));
try {
startActivity(webPageIntent);
} catch (ActivityNotFoundException ex) {
}
}
}
Make sure u add uses internet permission to the manifest!
you can refer the following to get an idea ,
see this vogella from there, you can get idea how to create android app which has a Button
http://www.vogella.de/articles/Android/article.html
and then create WebView in xml and map it in java, as
http://developer.android.com/resources/tutorials/views/hello-webview.html
and For mor info refer android people.com
http://www.androidpeople.com/
http://developer.android.com/resources/samples/index.html
and also read my blog to know about android basics
http://sankarganesh-info-exchange.blogspot.com/p/corridor-your-foremost-footstep-in.html
You would need to set up an OnClickListener and tie it to your button. In the Listener's onClick method, you would load the specified URL into the WebView, which, based on your comments, it sounds like you've got that part figured out.