PayPal Error - Please make sure all fields have been entered - android-emulator

I have a problem in creating a working PayPal button in Sandbox environment.
After entering my email and password in the sandbox environment.
This is what I see.
Here are my codes
AndroidManifest.xml
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MypaypalActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.paypal.android.MEP.PayPalActivity"
android:configChanges="keyboardHidden|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
</manifest>
MypaypalActivity
public class MypaypalActivity extends Activity implements OnClickListener{
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout MainLayout= new LinearLayout(this);
setContentView(R.layout.main);
PayPal pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
LinearLayout layoutSimplePayment = new LinearLayout(this);
layoutSimplePayment.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
layoutSimplePayment.setOrientation(LinearLayout.VERTICAL);
CheckoutButton COButton = pp.getCheckoutButton(this, PayPal.BUTTON_118x24, CheckoutButton.TEXT_PAY);
COButton.setOnClickListener(this);
layoutSimplePayment.addView(COButton);
MainLayout.addView(layoutSimplePayment);
setContentView(MainLayout);
}
public void onClick(View v) {
PayPalPayment payment = new PayPalPayment();
payment.setSubtotal(new BigDecimal("10"));
payment.setCurrencyType("USD");
payment.setRecipient("becozofeuu_92#hotmail.com");
// payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
Intent checkoutIntent = PayPal.getInstance().checkout(payment, this);
startActivityForResult(checkoutIntent, 1);
}

I faced same problem, finally I solve it using this code to
pass integer value to Bigdecimal
payment.setSubtotal(new BigDecimal("10"));
instead of using:
payment.setSubtotal(new BigDecimal(10));
e.g.:
public void onClick(View v) {
PayPalPayment payment = new PayPalPayment();
payment.setSubtotal(new BigDecimal("10"));
payment.setCurrencyType("USD");
payment.setRecipient("becozofeuu_92#hotmail.com");
// payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
Intent checkoutIntent = PayPal.getInstance().checkout(payment, this);
startActivityForResult(checkoutIntent, 1);
}

Related

App crashes saying 'Unfortunately, app has stopped' while using asmack

Here is my code for connecting to OpenFire through aSmack API. I am getting an error saying 'unfortunately app has stopped' when trying to run the app on my phone. When i remove the code of aSmack, the app is working fine with creating one button. I also have added the jars into the classpath. Please help me.
package com.example.demo;
import java.io.File;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Presence;
import android.os.Build;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
String username = "swapnil", password = "swapnil", host = "192.168.0.4", service = "mirana";
int port = 5222;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bt = (Button) findViewById(R.id.button1);
final EditText et =(EditText)findViewById(R.id.editText1);
bt.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
// et.setText("Test");
XMPPConnection xmpp = null;
ConnectionConfiguration xmppConfig = new ConnectionConfiguration("192.168.0.4", 5222,"mirana");
xmppConfig.setSASLAuthenticationEnabled(true);
xmppConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
if (xmppConfig == null)
throw new NullPointerException("XMPPService must be configured before it can connect!");
try {
if (xmpp == null) {
xmpp = new XMPPConnection(xmppConfig);
}
xmpp.connect();
} catch (XMPPException ex) {
et.setText("ERROR !");
}
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
And here is the manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.demo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Without log, after watching your code,what I can guess is that, you are running smack methods on Main Thread.. The exception should be of NetworkOnMainThreadException.
You should do the task, in your button click, on background threads. You might want to create AsyncTask for this.
Also, you dont have Internet permission. So please fix that too..
While implementing Smack, you need to take care of maintaining sessions of Smack Connections and related ones.. For this, you can refer the following the GitHub demo app: Smack Android Demo
You have to add Internet permission in your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
And you need to add below code in onCreate() method.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

Call an activity using Alarm Manager & Broadcast Receiver

I'm trying to create an app that automatically make phone calls after regular intervals to a specified number. I'm using Alarm Manager and Broadcast Receiver for this purpose. Alarm Manager can't initiate PHONE CALL activity and application terminates giving an error.
Here's my code. I am new in this Dev this.
*MainActivity.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private TextView label;
private EditText phoneNum;
private PendingIntent pendingIntent;
private AlarmManager manager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
label=(TextView)findViewById(R.id.entertextlabel);
phoneNum=(EditText)findViewById(R.id.phonenofield);
Intent alarmIntent = new Intent(this, AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);
//pendingIntent = PendingIntent.getActivity(this,1,alarmIntent,0);
}
public void startAlarm(View view) {
manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
int interval = 10000;
manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, pendingIntent);
Toast.makeText(this, "Alarm Set", Toast.LENGTH_SHORT).show();
}
public void cancelAlarm(View view) {
if (manager != null) {
manager.cancel(pendingIntent);
Toast.makeText(this, "Alarm Canceled", Toast.LENGTH_SHORT).show();
}
}
}
*AlarmReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
/**
* Created by Saud on 05/11/2015.
*/
public class AlarmReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent arg1) {
// For our recurring task, we'll just display a message
Toast.makeText(context, "I'm running", Toast.LENGTH_SHORT).show();
Intent in = new Intent(Intent.ACTION_CALL);
in.setData(Uri.parse("tel:03324310929"));
context.startActivity(in);
}
}
I'm getting error "Call requires user permission...."
at
context.startActivity(in);
*mainactivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Enter the Mobile number"
android:id="#+id/entertextlabel"
android:layout_centerHorizontal="true"
android:layout_marginTop="79dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Alarm"
android:id="#+id/button"
android:layout_alignParentBottom="true"
android:layout_toStartOf="#+id/callBtn"
android:layout_marginBottom="81dp"
android:onClick="startAlarm"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel Alarm"
android:id="#+id/button2"
android:layout_alignTop="#+id/button"
android:layout_toEndOf="#+id/callBtn"
android:onClick="cancelAlarm"/>
</RelativeLayout>
*Mantifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.saud.nexustelecom" >
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<receiver android:name=".AlarmReceiver"></receiver>
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The issue is resolved.
I used the Flag "FLAG_ACTIVITY_NEW_TASK" with with the intent in AlarmReceiver class.
New code is as follows
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
/**
* Created by Saud on 05/11/2015.
*/
public class AlarmReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent arg1) {
// For our recurring task, we'll just display a message
Toast.makeText(context, "I'm running", Toast.LENGTH_SHORT).show();
// Intent in = new Intent(Intent.ACTION_CALL);
//in.setData(Uri.parse("tel:03324310929"));
Intent in = new Intent(Intent.ACTION_CALL);
in.setData(Uri.parse("tel:03324310929"));
in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(in);
}
}

Opening Activity Crashes App

Hey guys I'm new to coding and iv'e recently been working on an app. I have set OnClickListener's to my buttons each leading to another class that I believe I stated in the Manifest. When I launch my app one of the buttons works but the other crashes the app and tells me that the class is not found please help. Here is some code:
public class CharPage extends ActionBarActivity {
private static Button button_next;
private static Button button_kk;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_char_page);
OnClickButtonListener();
}
public void OnClickButtonListener() {
{
button_kk= (Button) findViewById(R.id.buttonkk);
button_kk.setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent("com.example.jmac.mortalkombat.Kotal_Khan");
startActivity(intent);
}
}
);
}
button_next = (Button) findViewById(R.id.button);
button_next.setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent("com.example.jmac.mortalkombat.CharPage2");
startActivity(intent);
}
}
);
}
Then there is my Manifest:
<activity
android:name=".CharPage"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CharPage2"
android:label="#string/title_activity_char_page2" >
<intent-filter>
<action android:name="com.example.jmac.mortalkombat.CharPage2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CharPage3"
android:label="#string/title_activity_char_page3" >
<intent-filter>
<action android:name="com.example.jmac.mortalkombat.CharPage3" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Kotal_Khan"
android:label="#string/title_activity_kotal__khan" >
<intent-filter>
<action android:name="com.example.jmac.mortalkombat.Kotal_Khan" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
The StackTrace:
26010-26010/com.example.jmac.mortalkombat E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.jmac.mortalkombat, PID: 26010
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.jmac.mortalkombat.Kotal_Khan }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1801)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1499)
at android.app.Activity.startActivityForResult(Activity.java:3942)
at android.app.Activity.startActivityForResult(Activity.java:3889)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:820)
at android.app.Activity.startActivity(Activity.java:4213)
at android.app.Activity.startActivity(Activity.java:4181)
at com.example.jmac.mortalkombat.CharPage$1.onClick(CharPage.java:37)
at android.view.View.performClick(View.java:5197)
at android.view.View$PerformClick.run(View.java:20926)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
First make sure you have an Activity in your project that has this name "Kotal_Khan" and is under the package "com.example.jmac.mortalkombat" since this is what you declared in your manifest.
Second Replace.
Intent intent = new Intent("com.example.jmac.mortalkombat.Kotal_Khan");
for
Intent intent = new Intent(getApplicationContext(), YOURCLASSNAME.class);
i assume will be Kotal_Khan.class.
Good Luck.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_char_page);
button_kk= (Button) findViewById(R.id.buttonkk);
button_next = (Button) findViewById(R.id.button);
OnClickButtonListener();
}
public void OnClickButtonListener() {
{
button_kk.setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent("com.example.jmac.mortalkombat.Kotal_Khan");
startActivity(intent);
}
}
);
button_next.setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent("com.example.jmac.mortalkombat.CharPage2");
startActivity(intent);
}
}
);
}

RevMob no ads are displayed

I just update revmob with the last sdk (7.3.2) for Unity. I'm using Unity 4.5 Pro. Everything seems to work fine except that the ads isn't displayed. The debug say that the banner ad is displayed...but there is nothing on the screen and nothing to click either....Also I never get any Eula Popup at the launch of the game.
I think that I didn't missed anything in the doc (I maybe missed something that is why I need your help). All seems to be set as it said. I'm not using Proguard so I haven't do the googleplayservice proguard steps.
Here's the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:theme="#android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0" package="com.bas.revmobtesting" android:installLocation="preferExternal">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="false">
<activity android:label="#string/app_name" android:name="com.bas.revmobtesting.UnityPlayerNativeActivity" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
<activity android:configChanges="keyboardHidden|orientation" android:name="com.revmob.ads.fullscreen.FullscreenActivity" android:theme="#android:style/Theme.Translucent">
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="20" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
here's the simple script:
public class RevMobTesting : MonoBehaviour, IRevMobListener
{
private static readonly Dictionary<String, String> REVMOB_APP_IDS = new Dictionary<String, String> () {
{ "Android", "My_ANDROID_ID"},
{ "IOS", "My_IOS_ID" }
};
private RevMob revmob;
void Awake ()
{
revmob = RevMob.Start (REVMOB_APP_IDS, gameObject.name);
revmob.SetTestingMode (RevMob.Test.WITH_ADS);
revmob.PrintEnvironmentInformation ();
}
private void Start ()
{
#if UNITY_ANDROID || UNITY_IPHONE
RevMobBanner banner = revmob.CreateBanner ();
banner.Show ();
#endif
}
#region IRevMobListener implementation
public void SessionIsStarted ()
{
Debug.Log ("Session started.");
}
public void SessionNotStarted (string revMobAdType)
{
Debug.Log ("Session not started.");
}
public void AdDidReceive (string revMobAdType)
{
Debug.Log ("Ad did receive.");
}
public void AdDidFail (string revMobAdType)
{
Debug.Log ("Ad did fail.");
}
public void AdDisplayed (string revMobAdType)
{
Debug.Log ("Ad displayed.");
}
public void UserClickedInTheAd (string revMobAdType)
{
Debug.Log ("Ad clicked.");
}
public void UserClosedTheAd (string revMobAdType)
{
Debug.Log ("Ad closed.");
}
public void InstallDidReceive (string message)
{
Debug.Log ("Install received");
}
public void InstallDidFail (string message)
{
Debug.Log ("Install not received");
}
public void EulaIsShown ()
{
Debug.Log ("Eula is displayed");
}
public void EulaAccepted ()
{
Debug.Log ("Eula was accepted");
}
public void EulaRejected ()
{
Debug.Log ("Eula was rejected");
}
#endregion
}
Thanks in advance,
David
Don't know you solved the issue or not. I got the same problem when upgraded to 7.3.2. I used to use this line to create banner:
banner = revmob.CreateBanner(RevMob.Position.BOTTOM);
In 7.3.2, "AdDisplayed" event triggered, but no banner showing. Finally, I succeeded to summon the banner with codes like:
int bannerWidth = (int) Screen.width;
cost float bannerRatio = 6.4f;
int bannerHeight = (int) (Screen.width / bannerRatio);
banner = revmob.CreateBanner(RevMob.Position.TOP,
0, (int)(Screen.height - bannerHeight),
bannerWidth, bannerHeight);
It seems Position.BOTTOM doesn't work in 7.3.2. I'm also waiting for RevMob's reply.

NewActivity not resolving in base class - should/how do I get the base class to recognize it?

Using Eclipse on OSX:
I'm trying to start my first new activity from an Intent. The error seems to be here:
Intent newButton = new Intent(v.getContext(),RandomActivity.class);
startActivity(RandomActivity);
RandomActivity isn't getting resolved. I think I have it correct in my Manifest file. I think my imports are correct. Do I need to declare it somewhere in my base Activity? That doesn't seem to work. It's like the code doesn't recognize the existence of the new class, but I can't see where to fix that.
The rest of my code:
package course.examples.UI.Button;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import course.examples.UI.Button.R;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import course.examples.UI.Button.RandomActivity;
public class ButtonActivity extends Activity {
int count = 0;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent newButton = new Intent(v.getContext(),RandomActivity.class);
startActivity(RandomActivity);
^Multiple markers at this line
brandNewButton cannot be resolved to a type
RandomActivity cannot be resolved to a variable
Note: brandNewButton WAS a class, but I deleted it, then went File->New->Class to create RandomActivity.java.
}
});
}
}
My XML code is below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button
android:id="#+id/button"
android:text="Press Me!"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
>
</Button>
</RelativeLayout>
And here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="course.examples.UI.Button"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<application
android:allowBackup="false"
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name=".ButtonActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RandomActivity">
</activity>
</application>
</manifest>
Thanks in advance everyone, it's great to have such a community of support here for us noobies.
You don't really need to do :
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent newButton = new Intent(v.getContext(),RandomActivity.class);
Here's the issue: You are trying to start activity with different intent name ??
"startActivity(RandomActivity);" // Wrong intent name
Check your intent!
Instead, just try using this :
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent newButton = new Intent(ButtonActivity.this, RandomActivity.class);
startActivity(newButtom);//This is right
Also.. if your RandomActivity is not from your same package, register it with full path like:
<activity android:name="your packagename where random activity is.RandomActivity" />
Hope this helps.