Is it possible to integrate video ads from Flurry in an android app? I tried some things, but it didn't work. The Flurry Android SDK has the onVideoCompleted function, and in the Android Flurry SDK Release Notes, the following can be found: verified support for clips in AdUnity (http://support.flurry.com/index.php?title=Analytics/Code/ReleaseNotes/Android).
I tried this code, but it didn't work for me:
package com.test.flurrytest;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import com.flurry.android.FlurryAdType;
import com.flurry.android.FlurryAds;
import com.flurry.android.FlurryAdSize;
import com.flurry.android.FlurryAgent;
import com.flurry.android.FlurryAdListener;
public class MainActivity extends Activity implements AdCallbackListener, FlurryAdListener {
FrameLayout mBanner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mBanner = new FrameLayout(this);
FlurryAds.setAdListener(this);
FlurryAds.enableTestAds(true);
Button watchvideo = (Button) findViewById(R.id.watchvideo);
watchvideo.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
FlurryAds.fetchAd(MainActivity.this, "TestAdspace", mBanner, FlurryAdSize.FULLSCREEN);
FlurryAds.displayAd(MainActivity.this, "TestAdspace", mBanner);
}
});
}
// Flurry
#Override
public void onStart() {
super.onStart();
FlurryAgent.onStartSession(this, "****");
}
public void spaceDidReceiveAd(String adSpace) {
FlurryAds.displayAd(this, adSpace, mBanner);
}
public void onVideoCompleted(String adSpace) {
// The user get some points now
}
public boolean shouldDisplayAd(String adSpaceName, FlurryAdType type) {
return true;
}
public void onAdClosed(String adSpaceName) {
}
public void onRenderFailed(String adSpaceName) {
Toast.makeText(getApplicationContext(), "The video has failed to render. Try again.", Toast.LENGTH_LONG).show();
}
public void onApplicationExit(String adSpaceName) {
}
public void spaceDidFailToReceiveAd(String adSpaceName) {
Toast.makeText(getApplicationContext(), "Failed to receive ad. Try again.", Toast.LENGTH_LONG).show();
}
public void onAdClicked(String adSpaceName) {
}
public void onAdOpened(String adSpaceName) {
}
#Override
public void onStop() {
super.onStop();
FlurryAds.removeAd(this, "TestAdspace", mBanner);
FlurryAgent.onEndSession(this);
}
}
Is it possible with Android, and if so, how to integrate it?
Thanks!
Related
package com.example.hp.check2;
import android.content.Intent;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ArrayList data;
TextView tv;
Button speakButton;
public SpeechRecognizer sr;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
speakButton = (Button) findViewById(R.id.btn_speak);
sr = SpeechRecognizer.createSpeechRecognizer(this);
sr.setRecognitionListener(new listener());
tv=(TextView)findViewById(R.id.textView);
data=new ArrayList();
}
class listener implements RecognitionListener
{
#Override
public void onReadyForSpeech(Bundle params) {
Toast.makeText(MainActivity.this, "onReadyForSpeech", Toast.LENGTH_SHORT).show();
}
#Override
public void onBeginningOfSpeech() {
Toast.makeText(MainActivity.this, "onBeginningOfSpeech", Toast.LENGTH_SHORT).show();
}
#Override
public void onRmsChanged(float rmsdB) {
Toast.makeText(MainActivity.this, "onRmsChanged", Toast.LENGTH_SHORT).show();
}
#Override
public void onBufferReceived(byte[] buffer) {
Toast.makeText(MainActivity.this, "onbufferreceived", Toast.LENGTH_SHORT).show();
}
#Override
public void onEndOfSpeech() {
Toast.makeText(MainActivity.this, "onEndOfSpeech", Toast.LENGTH_SHORT).show();
}
#Override
public void onError(int error) {
Toast.makeText(MainActivity.this, "onError", Toast.LENGTH_SHORT).show();
}
#Override
public void onResults(Bundle results) {
String str = new String();
data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
for (int i = 0; i < data.size()+10; i++)
{
str += data.get(i)+"S";
}
tv.setText(str);
}
#Override
public void onPartialResults(Bundle partialResults) {
Toast.makeText(MainActivity.this, "onPartialReults", Toast.LENGTH_SHORT).show();
}
#Override
public void onEvent(int eventType, Bundle params) {
Toast.makeText(MainActivity.this, "onEvent", Toast.LENGTH_SHORT).show();
}
}
public void onClick(View v) {
if (v.getId() == R.id.btn_speak)
{
sr.startListening(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH));
}
}
}
When I am running the code,I am just getting the toast of onRmsChanged and nothing else and it continues till I close the application.And there is no method change when I try to speak as there is no new Toast appearing on the screen.I have read about onRmsChanged on internet but didn't get it much.I have granted the permission of microphone but still the problem occurs.Any idea what is going on?
I have attempted to integrate simple Unity shape figure to display using Android Studio IDE however it shows like this:
Your hardware does not support this application sorry
My phone is Android 6.0 Marshmallow and the version of Unity is 5.4.1f1
The logcat in Android Studio does not show any error except when I dismiss the message about hardware not supported, then crashed.
package com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.maps_class;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.R;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.SplashInterface;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.comic_class.comiclass;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.phone_class.phoneclass;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.scenario_class.scenarioclass;
import com.unity3d.player.UnityPlayer;
public class lcoldclass extends AppCompatActivity {
protected UnityPlayer mUnityPlayer;
public static Context mContext;
private Handler handler=new Handler();
public FrameLayout fl_forUnity;
public ImageButton scenario1, comic1, phoneclass1, maps1, homeb;
public Toolbar toolbar;
public TextView txttitle;
public void init_home() {
homeb= (ImageButton)findViewById(R.id.homebutton);
homeb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,SplashInterface.class);
startActivity(first);
}
});
}
public void init_scenario() {
scenario1= (ImageButton)findViewById(R.id.scenario);
scenario1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,scenarioclass.class);
startActivity(first);
}
});
}
public void init_comic() {
comic1= (ImageButton)findViewById(R.id.comicbutton);
comic1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,comiclass.class);
startActivity(first);
}
});
}
public void init_phone() {
phoneclass1= (ImageButton)findViewById(R.id.callbutton);
phoneclass1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,phoneclass.class);
startActivity(first);
}
});
}
public void init_maps() {
maps1= (ImageButton)findViewById(R.id.mapsl);
maps1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,SecondInterfaceF.class);
startActivity(first);
}
});
}
private void initToolbar() {
toolbar = (Toolbar) findViewById(R.id.include2);
toolbar.showOverflowMenu();
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
mContext = this;
getWindow().takeSurface(null);
setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
getWindow().setFormat(PixelFormat.RGB_888);
mUnityPlayer = new UnityPlayer(this);
if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
mUnityPlayer.init(glesMode, trueColor8888);
View playerView = mUnityPlayer.getView();
setContentView(R.layout.lcmapsold1);
this.fl_forUnity = (FrameLayout)findViewById(R.id.frameunity);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(750, 630);
fl_forUnity.addView(playerView, 0, lp);
initToolbar();
init_home();
init_scenario();
init_comic();
init_phone();
init_maps();
txtformation_init();
mUnityPlayer.requestFocus();
}
///////////////////////////// Unity Codes Override///////////////////////////////////////////
// Quit Unity
#Override protected void onDestroy ()
{
mUnityPlayer.quit();
super.onDestroy();
}
// Pause Unity
#Override protected void onPause()
{
super.onPause();
mUnityPlayer.pause();
}
// Resume Unity
#Override protected void onResume()
{
super.onResume();
mUnityPlayer.resume();
}
// This ensures the layout will be correct.
#Override public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
// Notify Unity of the focus change.
#Override public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
mUnityPlayer.windowFocusChanged(hasFocus);
}
// For some reason the multiple keyevent type is not supported by the ndk.
// Force event injection by overriding dispatchKeyEvent().
#Override public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
return mUnityPlayer.injectEvent(event);
return super.dispatchKeyEvent(event);
}
// Pass any events not handled by (unfocused) views straight to UnityPlayer
#Override public boolean onKeyUp(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
#Override public boolean onKeyDown(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
#Override public boolean onTouchEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
/*API12*/ public boolean onGenericMotionEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
///////////////////////////// Unity Codes Override///////////////////////////////////////////
}
How to solve it? I cannot understand how users manage to work the program without issues on integration.
The code is posted here and the app crashes when the login button is clicked with null pointer exception at homefragment on click.im a beginer.please help.logcat http://postimg.org/image/6d1qyszkd/
simple facebook class basically is :
public SimpleFacebook()
{
mSessionStatusCallback = new SessionStatusCallback();
}
public static void initialize(Activity activity)
{
if (mInstance == null)
{
mInstance = new SimpleFacebook();
}
mActivity = activity;
}
public static SimpleFacebook getInstance(Activity activity)
{
if (mInstance == null)
{
mInstance = new SimpleFacebook();
}
mActivity = activity;
return mInstance;
}
public static SimpleFacebook getInstance()
{
return mInstance;
}
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.GetDataCallback;
import com.sromku.simple.fb.SimpleFacebook;
import com.sromku.simple.fb.Properties;
import com.sromku.simple.fb.SimpleFacebook;
import com.sromku.simple.fb.SimpleFacebook.OnFriendsRequestListener;
import com.sromku.simple.fb.SimpleFacebook.OnLoginListener;
import com.sromku.simple.fb.SimpleFacebook.OnLogoutListener;
import com.sromku.simple.fb.SimpleFacebook.OnProfileRequestListener;
import com.sromku.simple.fb.entities.Profile;
import com.sromku.simple.fb.example.utils.Utils;
import com.sromku.simple.fb.utils.Attributes;
import com.sromku.simple.fb.utils.PictureAttributes;
import com.sromku.simple.fb.utils.PictureAttributes.PictureType;
public class HomeFragment extends Fragment {
protected static final String TAG = HomeFragment.class.getName();
private SimpleFacebook mSimpleFacebook;
ProgressDialog mProgress;
Button mButtonLogin;
Button mButtonLogout;
TextView mTextStatus;
// Login listener
private OnLoginListener mOnLoginListener = new OnLoginListener()
{
#Override
public void onFail(String reason)
{
mTextStatus.setText(reason);
Log.w(TAG, "Failed to login");
}
#Override
public void onException(Throwable throwable)
{
mTextStatus.setText("Exception: " + throwable.getMessage());
Log.e(TAG, "Bad thing happened", throwable);
}
#Override
public void onThinking()
{
// show progress bar or something to the user while login is happening
mTextStatus.setText("Thinking...");
}
#Override
public void onLogin()
{
// change the state of the button or do whatever you want
mTextStatus.setText("Logged in");
loggedInUIState();
toast("You are logged in");
}
#Override
public void onNotAcceptingPermissions()
{
toast("You didn't accept read permissions");
}
};
// Logout listener
private OnLogoutListener mOnLogoutListener = new OnLogoutListener()
{
#Override
public void onFail(String reason)
{
mTextStatus.setText(reason);
Log.w(TAG, "Failed to login");
}
#Override
public void onException(Throwable throwable)
{
mTextStatus.setText("Exception: " + throwable.getMessage());
Log.e(TAG, "Bad thing happened", throwable);
}
#Override
public void onThinking()
{
// show progress bar or something to the user while login is happening
mTextStatus.setText("Thinking...");
}
#Override
public void onLogout()
{
// change the state of the button or do whatever you want
mTextStatus.setText("Logged out");
loggedOutUIState();
toast("You are logged out");
}
};
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.homend_home_fragment, container, false);
// test local language
Utils.updateLanguage(getActivity(), "en");
Utils.printHashKey(getActivity());
mButtonLogin = (Button)rootView.findViewById(R.id.button_login);
mButtonLogout = (Button)rootView.findViewById(R.id.button_logout);
mTextStatus = (TextView)rootView.findViewById(R.id.text_status);
mButtonLogin.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View arg0)
{
mSimpleFacebook.login(mOnLoginListener);
}
});
// 2. Logout example
mButtonLogout.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View arg0)
{
mSimpleFacebook.logout(mOnLogoutListener);
}
});
return rootView;
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
mSimpleFacebook.onActivityResult(getActivity(), requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
private void setUIState()
{
if (mSimpleFacebook.isLogin())
{
loggedInUIState();
}
else
{
loggedOutUIState();
}
}
/**
* Show toast
*
* #param message
*/
private void toast(String message)
{
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
}
private void loggedInUIState()
{
mButtonLogin.setEnabled(false);
mButtonLogout.setEnabled(true);
mTextStatus.setText("Logged in");
}
private void loggedOutUIState()
{
mButtonLogin.setEnabled(true);
mButtonLogout.setEnabled(false);
mTextStatus.setText("Logged out");
}
private void showDialog()
{
mProgress = ProgressDialog.show(getActivity(), "Thinking",
"Waiting for Facebook", true);
}
private void hideDialog()
{
mProgress.hide();
}
public class OnProfileRequestAdapter implements OnProfileRequestListener
{
#Override
public void onThinking()
{
}
#Override
public void onException(Throwable throwable)
{
}
#Override
public void onFail(String reason)
{
}
#Override
public void onComplete(Profile profile)
{
}
}
}
I think problem might be here. You have just declared your variable
private SimpleFacebook mSimpleFacebook;
you haven't initialized that variable so you got NPE
So initialized it on onCreateView() method.
mSimpleFacebook = SimpleFacebook.getInstance(getActivity());
And yet you get error then you need to finally change
mSimpleFacebook = SimpleFacebook.getInstance();
Add this line to manifest file..
<activity android:name="com.facebook.LoginActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
</activity>
which would be finally works for you.!!
hello all i m new android person and i m trying to make an app that login with linked in but it throw exception java.lang.NoClassDefFoundError: org.brickred.socialauth.android.SocialAuthAdapter and crash the app. Below is my code
package com.example.demosocialapp;
import org.brickred.socialauth.android.DialogListener;
import org.brickred.socialauth.android.SocialAuthAdapter;
import org.brickred.socialauth.android.SocialAuthAdapter.Provider;
import org.brickred.socialauth.android.SocialAuthError;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
SocialAuthAdapter adapter;
Button update;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button share = (Button) findViewById(R.id.button1);
adapter = new SocialAuthAdapter(new ResponseListener());
adapter.enable(share);
share.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
adapter.authorize(MainActivity.this, Provider.LINKEDIN);
}
});
}
private final class ResponseListener implements DialogListener {
#Override
public void onComplete(Bundle values) {
final String providerName = values.getString(SocialAuthAdapter.PROVIDER);
Toast.makeText(MainActivity.this, providerName + " connected", Toast.LENGTH_LONG).show();
}
#Override
public void onError(SocialAuthError error) {
Log.d("ShareButton", "Authentication Error: " + error.getMessage());
}
#Override
public void onCancel() {
Log.d("ShareButton", "Authentication Cancelled");
}
#Override
public void onBack() {
Log.d("Share-Button", "Dialog Closed by pressing Back Key");
}
}
}
But when i clicked on button it give error with crash : java.lang.NoClassDefFoundError: org.brickred.socialauth.SocialAuthManager
Please help me....................
I am not sure, but I had the same Exception with another libraries.
I think you should configure your build path:
Right click on project - Build Path - Configure Build Path... - Order and Export
Then check your library and raise it up to the top
I'm trying to start a very simple jWebSocket Client on Android and connect it to my local server. I'm using the JWC class from the demo together with jWebSocket 1.0 beta 8 and Android 4.0.3, my code looks like this:
import org.jwebsocket.api.WebSocketClientEvent;
import org.jwebsocket.api.WebSocketClientTokenListener;
import org.jwebsocket.api.WebSocketPacket;
import org.jwebsocket.client.token.BaseTokenClient;
import org.jwebsocket.kit.WebSocketException;
import org.jwebsocket.token.Token;
import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import cased.smids.communication.JWC;
public class TasksActivity extends Activity implements WebSocketClientTokenListener {
Spinner spinner;
Button btn_Start;
/** Called when the activity is first created. */
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
JWC.init();
spinner = (Spinner)findViewById(R.id.sp_Task);
btn_Start = (Button)findViewById(R.id.btn_Start);
ArrayAdapter<CharSequence> adapter =
ArrayAdapter.createFromResource(
this,
R.array.Tasks,
android.R.layout.simple_spinner_item
);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
btn_Start.setOnClickListener(new View.OnClickListener() {
public void onClick(View src) {
switch (src.getId()) {
case R.id.btn_Start:
if (spinner.getSelectedItem().toString().equals("Connect")) {
try {
System.out.println("connecting manually...");
JWC.open();
} catch (WebSocketException e) {
e.printStackTrace();
}
}
default:
break;
}
}
});
}
#Override
protected void onResume() {
super.onResume();
System.out.println("* opening... ");
try {
JWC.addListener(this);
JWC.open();
} catch (WebSocketException ex) {
System.out.println("* exception: " + ex.getMessage());
}
}
#Override
protected void onPause() {
System.out.println("* closing... ");
try {
JWC.close();
JWC.removeListener(this);
} catch (WebSocketException ex) {
System.out.println("* exception: " + ex.getMessage());
}
super.onPause();
}
public void processClosed(WebSocketClientEvent arg0) {
System.out.println("closed");
}
public void processOpened(WebSocketClientEvent arg0) {
System.out.println("opened");
}
public void processOpening(WebSocketClientEvent arg0) {
System.out.println("opening");
}
public void processPacket(WebSocketClientEvent arg0, WebSocketPacket arg1) {
System.out.println("packet");
}
public void processReconnecting(WebSocketClientEvent arg0) {
System.out.println("reconnecting");
}
public void processToken(WebSocketClientEvent arg0, Token arg1) {
System.out.println("token");
}
}
so basically it's just a spinner and a button. For now, all I want to do is connect to my local jWebSocketServer. The demo-app (the .apk package from the website, if I import the code eclipse tells me to remove many "#Overwrite" before it compiles the code - after that same "bug" occurs) works with my server so it has to be the code. Right now all I get is "connecting..." and about 0.1s later "closed". Every time.
btw. the app has the right INTERNET and ACCESS_NETWORK_STATE so that shouldn't be a problem.
i will be grateful for any help.
Cheers
Turns out, BaseTokenClient.open() is catching all exceptions and doing nothing about it (silent fail). In my case - NetworkOnMainThreadException. Mystery solved.