I am trying to implement facebook like slider, and i am planning to user below opensource code
https://github.com/leonardosalles/shipp-sliding-menu
but after i integrate, i created a sample activity
as per the code guide, in the
PrincipalActivity.java
//intent = new Intent(this, MyNewActivity2.class);
if it try giving my class, i get below error
cannot find symbol constructor Intent(,java.lang.Class)
here is my activity class
import android.app.Activity;
import android.os.Bundle;
public class SampleFirstTest extends Activity
{
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
please Help me to resolve the issue, i am new to android..
add SampleFirstTest in your AndroidManifest.xml
Related
I am trying to integrate the FireBase Auth UI into my Android app and I am following the Firebase tutorial for setting up authentication. When I am using
package com.example.kishan.basicproject;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.firebase.ui.auth.AuthUI;
import java.util.Arrays;
import java.util.List;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
private static final int RC_SIGN_IN = 123;
// ...
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
}
The error I get in Android Studio is "cannot resolve getInstance()" or "invalid method declaration; return type required". I have searched on Firebase forums, but have not found help. I was wondering if someone could point me in the correct direction? Thank you for all your help!!
this happens to my once and what i did was to include the startActivityForResult() inside the onCreate() method, something like this:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startActivityForResult(AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
}
I followed up this and works https://firebase.google.com/docs/auth/android/firebaseui
I am trying to make a PPT viewer app.I have added the pptViewer library in my project from https://github.com/itsrts/pptviewer-android.
But I am getting an error called "cannot resolve symbol 'activity'" on this line pptViewer.loadPPT(activity,"/home/waheed/lab6.pptx").Please help.
Below is my code:
package com.example.waheed.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.itsrts.pptviewer.PPTViewer;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PPTViewer pptViewer = (PPTViewer) findViewById(R.id.pptviewer);
pptViewer.setNext_img(R.drawable.next)
.setPrev_img(R.drawable.prev)
.setSettings_img(R.drawable.settings)
.setZoomin_img(R.drawable.zoomin)
.setZoomout_img(R.drawable.zoomout);
pptViewer.loadPPT(activity,"/home/waheed/lab6.pptx");
}
}
activity isn't a defined symbol, but . In this case, since the code is in an activity, use the current object:
pptViewer.loadPPT(this, "/home/waheed/lab6.pptx");
You probably copy-pasted from the readme, as the activity used as sample method input in the readme means you have to pass an activity instance. You don't declare Activity activity = ..., but since you're in an activity you can use this
pptViewer.loadPPT(this,"/home/waheed/lab6.pptx");
Try this:
pptViewer.loadPPT(MainActivity.this,"/home/waheed/lab6.pptx");
You reference activity in your code which is not defined. Pass current class instead of the undefined field.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PPTViewer pptViewer = (PPTViewer) findViewById(R.id.pptviewer);
pptViewer.setNext_img(R.drawable.next)
.setPrev_img(R.drawable.prev)
.setSettings_img(R.drawable.settings)
.setZoomin_img(R.drawable.zoomin)
.setZoomout_img(R.drawable.zoomout);
pptViewer.loadPPT(MainActivity.this,"/home/waheed/lab6.pptx");
}
My app crashes straight away with an exception
Here is the code of my main activity
package com.example.orientation;
import android.os.Bundle;
import android.app.FragmentManager;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
public class MainActivity extends ActionBarActivity implements myList.Communication {
myList listFragment;
Details detailsFragment;
FragmentManager manager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager=getFragmentManager();
listFragment = (myList) manager.findFragmentById(R.id.listFragment);
listFragment.setCommunicator(this);
}
#Override
public void respond(int index) {
detailsFragment = (Details) manager.findFragmentById(R.id.detailFragment);
if (detailsFragment!=null && detailsFragment.isVisible()) {
detailsFragment.changeData(index);
}else{
Intent intent = new Intent(this,DetailActity.class);
intent.putExtra("index",index);
startActivity(intent);
}
}
}
I tried reading documentation but could not get how to solve this. Any help will be appreciated. Thank You.
If you have only added android support jar, you must add the whole Appcompat project to your workspace:
right click -> IMport -> Android -> Project from Existing Source
Then go to SDK Folder where you installed and find extras/android/support/v7/appcompat
and add this whole Library.
It seems like you are missing resources needed for ActionBarActivity
hey i am new to android development. i tried exporting my app the process failed because of some minor errors and then i got errors all over my code. it was working perfectly fine with no errors before attempting to export.
check these two pics of the xml files where the errors popped up
main activity file: http://postimg.org/image/4gwdipnap/
second activity file: http://postimg.org/image/vuy1ryba3/
I didn't have any of these errors before trying to export the project.
heres the code for both of the files
main activity page
package youngadults.camden;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
public class FrontPage extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.front_page);
findViewById(R.id.uyounadults).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent myIntent = new Intent(FrontPage.this, youngadultsp.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(myIntent);
}
});
}
}
second activity page
package youngadults.camden;
import android.app.Activity;
import android.os.Bundle;
public class youngadultsp extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.youngadultsp_1);
}
}
You need to set Android API level, do you use Android Studio or Eclipse?
For Eclipse edit your Manifest file (19 is example):
<uses-sdk android:minSdkVersion="19" />
For Android Studio
Right click the App directory
Select "Open Module Setting" at the bottom
Under Modules select app
Set 'Compile Sdk version' as you want
I followed the example of a Android book to draft a project.
However, there are some problems coming out:
When I touch a selection, the program will exit the program and returning a message "the application has stopped unexpectedly. Please try again"
Would anyone can help me?
here is the source code:
package com.example.ch07_dialogask;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity //should be protected
implements DialogInterface.OnClickListener{
TextView txv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txv = (TextView)findViewById(R.id.answer);
new AlertDialog.Builder(this)
.setMessage("Do you like Android phone?")
.setCancelable(false)
.setIcon(android.R.drawable.ic_menu_edit)
.setTitle("Android survey")
.setPositiveButton("Like",this)
.setNegativeButton("Unlike",this)
.setNeutralButton("No Comment",null)
.show();
}
#Override
public void onClick(DialogInterface dialog, int id){
if(id==DialogInterface.BUTTON_POSITIVE){
txv.setText("You Like Android Phone!");
}
else if(id==DialogInterface.BUTTON_NEGATIVE){
txv.setText("You Dislike Android Phone.....");
}
}
Sorry, I can't comment yet. I don't have 50 reputation points yet.
Anyway, try putting the "new AlertDialog.Builder..." snippet on the onResume method of the activity.
I would bet that this is happening because the onCreate method isn't showing the layout yet. You can learn more about the Activity life cycle here: Android Developer: Activity. Also, try posting the Logcat with your questions. It helps a lot to learn what is going on.
Hope this helps you!
EDIT:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txv = (TextView)findViewById(R.id.answer);
}
#Override
public void onStart(){ //Called when the activity is becoming visible to the user.
super.onStart();
new AlertDialog.Builder(this)
.setMessage("Do you like Android phone?")
.setCancelable(false)
.setIcon(android.R.drawable.ic_menu_edit)
.setTitle("Android survey")
.setPositiveButton("Like",this)
.setNegativeButton("Unlike",this)
.setNeutralButton("No Comment",null)
.show();
}