Cannot resolve method 'getInstance()' - java

I was watching a youtube tutorial (Firebase storage and around 14 minutes I got this error code:
Cannot resolve method 'getInstance()'
Can someone help me resolve it? I am pretty new to Java and have been watch tutorials to get the understanding right. I know this is a small detail, but it has been really frustrating.
package bfb.ess.myapplicationbfb;
import android.app.ProgressDialog;
import android.media.MediaRecorder;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.UploadTask;
import java.io.File;
import java.io.IOException;
public class speakp extends AppCompatActivity {
private Button mRecordBtn;
private TextView mRecordlabel;
private MediaRecorder mRecorder;
private String mFileName = null;
private static final String LOG_TAG = "Record_log";
private StorageReference mStorage;
private ProgressDialog mProgress;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recordpage);
mStorage = FirebaseStorage.getInstance().getReference(); /*RIGHT HERE*/
mRecordlabel = (TextView) findViewById(R.id.recordlabel);
mRecordBtn =(Button) findViewById(R.id.recordBtn);

Related

How to fix RecognitionEngine error on android app using API.ai

I've been following some tutorials on how to make an app with API.ai integrated with it. But so far, unlike the tutorials, it gives me an error when I apply the Recognition Engine. This is the code on my Manifest.
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import ai.api.AIConfiguration;
import ai.api.AIListener;
import ai.api.android.AIService;
import ai.api.model.AIError;
import ai.api.model.AIResponse;
import ai.api.model.Result;
import ai.api.ui.AIButton;
public class MainActivity extends AppCompatActivity implements AIListener{
private AIService aiService;
TextView t;
#Override
protected void onCreate(Bundle savedInstanceState) {
AIService aiService;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t=findViewById(R.id.textView);
int permission = ContextCompat.checkSelfPermission(this,
Manifest.permission.RECORD_AUDIO);
if (permission != PackageManager.PERMISSION_GRANTED) {
makeRequest();
}
final AIConfiguration config = new AIConfiguration("CLIENT_ACCESS_TOKEN",
AIConfiguration.SupportedLanguages.English,
AIConfiguration.RecognitionEngine.System);
aiService = AIService.getService(this, (ai.api.android.AIConfiguration) config);
aiService.setListener(this);
}
This line of code: AIConfiguration.RecognitionEngine.System);
I have all the dependencies that API.ai requests to add to the app gradle.
It says "Cannot resolve the symbol". Does anyone know why this error occurs or how to fix it?
You need to add "import ai.api.android.AIConfiguration;"

Inconvertible type cannot cast android.view.view to javafx.scene.web.webview

i want to show my post in webview but i fatch error of "Inconvertible type cannot cast android.view.view to javafx.scene.web.webview" in android studio.
how can i solve it please help me.
WPPostDetails.java
package com.ejobbox.ejobbox;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import javafx.scene.web.WebView;
public class WPPostDetails extends AppCompatActivity {
TextView title;
WebView webView;
#Override
public void onCreate(#Nullable Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_postdetails);
title=(TextView) findViewById(R.id.title);
webView= (WebView) findViewById(R.id.postwebview);
Intent i = getIntent();
int position = i.getExtras().getInt("itemPosition");
//title.setText(MainActivity.mListPost.get(position).getTitle().getRendered());
Log.e("WpPostDetails","title is"+MainActivity.mListPost.get(position).getTitle().getRendered());
webView.getSettings().setJavaScriptEnabled(true);
}
}
You import a wrong WebView class. Remove import javafx.scene.web.WebView; and add import android.webkit.WebView
Import
android.webkit.WebView instead of
javafx.scene.web.WebView;

Attempting to implement LocationListener in Android Java

I am attempting to currently create an Android app that will follow a user's route of travel. Although at this point I am simply attempting to get their current location. I have attempted several methods involving LocationListeners and the like, but either get no result or errors that the guide never mentions. Some use it in the HTML5 pages but I don't really know enough to do it that way. Below I have the code that, in theory, should get the user's location and place a marker there.
Admittedly there are a lot of imports, mostly from me stumbling my way through this project and trying different locations to other problems that have popped up. The end result will be that the user completes a perimeter of something and it will get the area. While getting the area from a series of LatLngs is doable, the problem is getting the actual perimeter drawn by the user walking it. I am hoping to, at the moment, get the user's location repeatedly into a list of LatLngs and use that, but I am open to other suggestions.
package ideo.farmerhelp;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Looper;
import android.support.v4.app.FragmentActivity;
import android.graphics.Color;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import android.app.Activity;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Result;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.api.zzc;
import com.google.android.gms.common.api.zzl;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.PolygonOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.maps.android.SphericalUtil;
import com.google.android.gms.maps.GoogleMap.OnMarkerDragListener;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, OnMarkerDragListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener, android.location.LocationListener, GoogleMap.OnMapClickListener {
TextView tv;
private GoogleApiClient mGoogleApiClient;
public static final String TAG = MapsActivity.class.getSimpleName();
private final static int CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000;
private LocationRequest mLocationRequest;
private GoogleMap mMap;
SupportMapFragment mapFragment;
TextView txtlat;
String lat;
String provider;
protected String latitude, longitude;
protected boolean gps_Enabled, network_enabled;
#Override
protected void onCreate(Bundle savedInstanceState) { //On map create
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map); //Create a support map fragment
mapFragment.getMapAsync(this);
tv = (TextView) findViewById(R.id.area);
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new myLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll); //Requests that I cast the fourth parameter to android.location.LocationListener, doing so results in a castexception.
}
}

android studio cannot resolve method(), ignoring import

I'm a total noob at android studio, and I have a (to me) weird problem. I have inserted a button in my XML document:
<Button
android:layout_width="match_parent"
android:layout_height="127dp"
android:text="SUM"
android:id="#+id/button"
android:layout_row="15"
android:layout_column="0" />
And in the java code I would like a to make it do something when i click on it. However in code (I know there is way too many import):
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class TestActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
R.id.button.onCliclistener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent action) {
DO THIS WHEN CLICKED ON
}
});
}
BUT it says: Cannot resolve method() and Cannot resolve symbol, to the onCliclistener and ActionListener. And it says: unused import statement, to thier imports. It's probably a stupid question, but what am I doing wrong?
Nicolaj
Try making reference to your button in your onCreate method and then create an onClick method.
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class TestActivity extends AppCompatActivity implements View.OnClickListener {
Button btn;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
btn = (Button) findViewById(R.id.button); //Reference to the button
btn.setOnClickListener(this);
}
#Override
public void onClick(View v) {
DO THIS WHEN CLICKED ON
}
}
I expect it will be helpful for you!

Android crashing on activity start

Android crashes whenever this activity is started. here is the code.
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class SettingsActivity extends Activity {
EditText vname, vphone, vemail, vaddress;
TextView textDeviceID;
Button settings_submit;
#Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.settingmenu);
vname = (EditText) findViewById(R.id.get_name);
vphone = (EditText) findViewById(R.id.get_phone);
vemail = (EditText) findViewById(R.id.get_email);
vaddress = (EditText) findViewById(R.id.get_address);
settings_submit = (Button) findViewById(R.id.settings_submit);
settings_submit.setOnClickListener(settings_submitOnClickListener);
TextView textDeviceID = (TextView) findViewById(R.id.deviceid);
super.onCreate(savedInstanceState);
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
you should tell us more details. But I see that everything looks fine, except that
super.onCreate(savedInstanceState);
should go before setContentView() and all other stuff. By the way, check your xml for bad config controls too.

Categories