Cannot cast from View to XYPlot - eclipse

Im getting error at the bold line inside XYPlot.java class.
XYPlot.java :
package com.arise.plotme;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.series.XYSeries;
import com.androidplot.xy.*;
import com.arise.plotme.R;
import java.util.Arrays;
/**
* The simplest possible example of using AndroidPlot to plot some data.
*/
public class XYPlot extends Activity
{
private XYPlot mySimpleXYPlot;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.plot_xml);
// initialize our XYPlot reference:
**mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);**
// Create a couple arrays of y-values to plot:
Number[] series1Numbers = {12,2,4,3};// --x -lat
// Number[] series2Numbers = {1,2,10,3};
Number[] series3Numbers = {2,12,-2,7};// --y -lon
// Turn the above arrays into XYSeries':
XYSeries series1 = new SimpleXYSeries(
Arrays.asList(series1Numbers), // --x // SimpleXYSeries takes a List so turn our array into a List
//SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
Arrays.asList(series3Numbers),//--y
"Series1"); // Set the display title of the series
// same as above
// XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");
// Create a formatter to use for drawing a series using LineAndPointRenderer:
LineAndPointFormatter series1Format = new LineAndPointFormatter(
Color.rgb(0, 200, 0), // line color
Color.rgb(0, 100, 0), // point color
null); // fill color (none)
// add a new series' to the xyplot:
**mySimpleXYPlot.addSeries(series1, series1Format);**
// same as above:
//mySimpleXYPlot.addSeries(series2,
// new LineAndPointFormatter(Color.rgb(0, 0, 200), Color.rgb(0, 0, 100), null));
// reduce the number of range labels
**mySimpleXYPlot.setTicksPerRangeLabel(3);**
// by default, AndroidPlot displays developer guides to aid in laying out your plot.
// To get rid of them call disableAllMarkup():
**mySimpleXYPlot.disableAllMarkup();**
}
}
*plot_xml.xml :*
<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:paddingBottom="#+dimen/activity_vertical_margin"
android:paddingLeft="#+dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".XYPlot" >
<com.arise.plotme.XYPlot
android:id="#+id/mySimpleXYPlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
title="XY Plot me"/>
</RelativeLayout>
*Plot_Me MAnifest :*
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arise.plotme"
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.arise.plotme.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>
<activity
android:name="com.arise.plotme.XYPlot"
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>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Actually I have two layout of xml because I have two activity.
This is my second activity, my first activity contain no error.
Any helps are much appreciated.

Please replace your manifest file to this.
<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.arise.plotme.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>
<activity
android:name="com.arise.plotme.XYPlot"
android:label="#string/app_name" >
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

Related

share list of Images from gallery and any type of files from outside our application:

I'm trying to share a list of images from the gallery into my app to use it recycler view
or any thing else
<activity
android:icon="#mipmap/ic_launcher"
android:name=".MainActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
that works:-
1-specify these lines on the manifest
<activity
android:icon="#mipmap/ic_launcher"
android:name=".MainActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="*/*"/>
<data android:mimeType="image/jpeg" />
<data android:mimeType="image/png" />
<data android:mimeType="image/jpg" />
</intent-filter>
</activity>
2-Second get the action that opened your intent and check if its the one we registered for the activity and then the data is received as ArrayList of Uri
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
Bundle extras = intent.getExtras();
if (extras.containsKey(Intent.EXTRA_STREAM)) {
ArrayList<Uri> urisArrayList = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
urisArrayList.forEach(i-> Log.d(TAG, "onCreate: "+i.toString()));
}
}}

Android Facebook Login button XML error

I want to create a test project works 'facebook login'.
I made with reference to the developers site and blog equal, But I met with an error message on xml.
[error massage]
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebooktest.zoit.facebooktest/com.facebooktest.zoit.facebooktest.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.facebook.login.widget.LoginButton
[xml]
<com.facebook.login.widget.LoginButton
android:id="#+id/facebook_login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="30dp" />
[Manifest]
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebooktest.zoit.facebooktest">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
</manifest>
[MainActivity]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
facebookLoginButton.registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {...
...
public void onActivityResult(...
void geHashKey(){...
void geHashKey(){ ...
public void onResume(){ ...
public void onPause(){...
Do you know what's wrong? please help.
I know!
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
setContentView(R.layout.activity_main);
"setContentView(R.layout.activity_main);"
I succeeded to move the this code below to Facebook code.

How can I create a project in Android Studio to function default SMS app

Continuation of the previous query, see: SMS Receiver for AND API 19 and higher
I need to make the application run in the background and I could have it after installing the set as a default as shown here: http://android-developers.blogspot.cz/2013/10/getting-your-sms-apps-ready-for-kitkat.html
So I asked how to create a project to display a list of the "Super Duper SMS," which finally set as default.
The whole program must running as a service, without the need any screen for basic functions Receive SMS and should be registered in the core android
Thanks for any advice
I am tried with this code it help me...
manifests.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newsmsapp">
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/smsicon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.example.newsmsapp.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity android:name="com.example.newsmsapp.ComposeSMS">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="sms"/>
<data android:scheme="smsto"/>
<data android:scheme="mms"/>
<data android:scheme="mmsto"/>
</intent-filter>
</activity>
<receiver
android:name="com.example.newsmsapp.SMSReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>
<activity
android:name="com.example.newsmsapp.NotificationView"
android:label="#string/title_activity_notification_view"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<receiver android:name="com.example.newsmsapp.MMSReceiver" android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER"/>
<data android:mimeType="application/vnd.wap.mms-message"/>
</intent-filter>
</receiver>
<service android:name="com.example.newsmsapp.HandlessSMSSendService"
android:exported="true"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE"/>
<data android:scheme="sms"/>
<data android:scheme="smsto"/>
<data android:scheme="mms"/>
<data android:scheme="mmsto"/>
</intent-filter>
</service>
</application>
then create 4 file for smsReader,mmsReader,ComposeSMS,HeadlessSMSservice
smsReader.java
public class SMSReceiver extends BroadcastReceiver {
Notification notification;//=new Notification(R.drawable.icon,"New Message",System.currentTimeMillis());
NotificationManager notificationmaneger;
String SMSmsg;
public SMSReceiver() {
}
public static final String SMS_BUNDLE = "pdus";
#Override
public void onReceive(Context context, Intent intent) {
Bundle intentExtras = intent.getExtras();
if (intentExtras != null) {
Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
String smsMessageStr = "";
for (int i = 0; i < sms.length; ++i) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);
String smsBody = smsMessage.getMessageBody().toString();
String address = smsMessage.getOriginatingAddress();
smsMessageStr += "SMS From: " + address + "\n";
smsMessageStr += smsBody + "\n";
builder.setAutoCancel(true);
// builder.setTicker("this is ticker text");
builder.setContentTitle("New Messge");
builder.setContentText(SMSmsg);
builder.setSmallIcon(R.drawable.smsicon);
builder.setColor(context.getResources().getColor(R.color.colorAccent));
builder.setContentIntent(pendingIntent);
builder.setOngoing(true);
// builder.setSubText("You have pending tax"); //API level 16
//builder.setNumber(100);
builder.build();
}
SMSmsg=smsMessageStr;
}
}
mmsReader.java
public class MMSReceiver extends BroadcastReceiver
{
public MMSReceiver()
{
}
#Override
public void onReceive(Context context, Intent intent) {
}
}
ComposeSMS.java
public class ComposeSMS extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
}
}
HeadlessSMSservices.java
public class HandlessSMSSendService extends Service {
#Nullable
#Override
public IBinder onBind(Intent intent) {
return null;
}
}
if u want to see SMS then add listview in composeSMS.java and bind received data from sms table to listview adapter.

Revmob Unity : Banner ads not clickable

I am developing a game which required to show Revmob Banner ads.
I can successfully show banner ads, but can't not click on it. It's media id is into testing mode.
My code for it is below.
private RevMob rev mob;
void Awake() {
revmob = RevMob.Start(REVMOB_APP_IDS, "RevMob");
}
void Start() {
revmob.CreateBanner(RevMob.Position.BOTTOM);
revmob.ShowBanner(RevMob.Position.BOTTOM);
}
Please help me.
Try adding the following line in the AndroidManifest.xml file within the activity tags for UnityPlayerNativeActivity
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
Example
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="false" android:largeHeap="true">
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="#string/app_name" 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>

import com.google.ads.*; doesn't have AdManager

I'm really stuck here, trying to set a banner with ads-admob to my android app. I have done all the layout settings in the main.xml, also worked in the manifest file with the permissions, tried both XML and JAVA methods to show the ads and trying to make it work but I always get "could not get currentAdManager" from logcat in Eclipse. The application also crashes here, but works just fine without the admob settings. My admob SDK is GoogleAdMobAdsSdk-6.0.1.jar and I'm developing using phonegap .
I noticed that the command "import com.google.ads.*;" doesn't have the "AdManager" because when I insert individually the "import com.google.ads.AdManager;", I receive the error message "The import com.google.ads.AdManager cannot be resolved". My files:
My JAVA:
> package what.car.notes;
>
> import android.os.Bundle;
> import org.apache.cordova.*;
> import com.google.ads.AdView;
> import com.google.ads.AdManager; **- ERROR APEARS HERE**
> import com.google.ads.*;
>
> public class Cargeous21forActivity 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");
> setContentView(R.layout.main);
>
> dView adView = (AdView)this.findViewById(R.id.AdView);
> adView.loadAd(new AdRequest());
> }
> }
My LAYOUT file (main.xml):
> <?xml version="1.0" encoding="utf-8"?>
>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
> xmlns:myapp="http://schemas.android.com/apk/res/what.car.notes"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"
> android:orientation="vertical">
>
> <com.admob.android.ads.AdView
> android:id="#+id/AdView"
> android:layout_width="fill_parent"
> android:layout_height="wrap_content"
> myapp:backgroundColor="#000000"
> myapp:primaryTextColor="#FFFFFF"
> myapp:secondaryTextColor="#CCCCCC"
> />
>
> </LinearLayout>
My MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="what.car.notes"
android:versionCode="4"
android:versionName="1.3" >
<uses-sdk android:minSdkVersion="7" />
<uses-library
android:name="com.google.ads.AdManager" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:value="i've put my correct id here" android:name="ADMOB_PUBLISHER_ID" />
<activity android:name="com.admob.android.ads.AdMobActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboard|keyboardHidden"
android:value="SQLite-NDK" />
<!-- Track Market installs -->
<receiver android:name="com.admob.android.ads.analytics.InstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
And finally, the attrs.xml:
> <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable
> name="com.admob.android.ads.AdView"> <attr name="backgroundColor"
> format="color" /> <attr name="primaryTextColor" format="color" />
> <attr name="secondaryTextColor" format="color" /> <attr
> name="keywords" format="string" /> <attr name="refreshInterval"
> format="integer" /> </declare-styleable> </resources>
Does anyone have already been through such a thing?
Please read the getting started guide for the Google AdMob SDK on Android. The example from which you got that code is from an old Google ads SDK before the Google AdMob Ads SDK rewrite.
Issues I can see on first pass:
You're manifest's activity definition is incorrect. See this page for the correct AdActivity activity definition.
You don't need attrs.xml. The SDK includes these attributes now.
I don't think the publisher id can be a meta-vale. You must specify the publisher id in your AdView XML definition.
Your AdView XML definition needs to have an adSize.
The new Google AdMob SDK doesn't have a com.google.ads.AdManager class.
Thanks Eric! Your answer helped me a lot to find the right code. The final code looks like this:
JAVA:
import android.os.Bundle;
import org.apache.cordova.*;
import android.app.Activity;
import android.os.Handler;
import com.google.ads.*;
import android.widget.*;
import android.widget.LinearLayout;
public class myactActivity extends DroidGap {
private static final String MY_AD_UNIT_ID = "a14fd7e04e46295";
private AdView adView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
//
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
LinearLayout layout = super.root; // this is the only change from the sample
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
}
My layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
<com.google.ads.GoogleAdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxxxxxxxxxxxxxxxxxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</LinearLayout>
EVerthing worked since then... BUT! YEs, there is a but... 2 days later, with the incredible amount of $0,00 and 150 ads solicitacion, admob/google canceled my account!! I had heard their method are weird and remove developers for no reason at all and, with $0,00 and 150 views they cut me off of their program. Good part: I found some other ad services better than admob, but the minus side is that I'll have to figure out the code all over again...
Thanks anyway Eric!