-4

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");
}
}
Zoe
  • 27,060
  • 21
  • 118
  • 148

4 Answers4

1

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

Zoe
  • 27,060
  • 21
  • 118
  • 148
0
pptViewer.loadPPT(this,"/home/waheed/lab6.pptx");
Anton Kazakov
  • 2,740
  • 3
  • 23
  • 34
  • @KapilRajput this is the code fragment which will fix author's problem, so it's an answer – Anton Kazakov Jan 16 '18 at 13:07
  • it is an answer, but it's very low quality. Just a snippet without any explanation isn't likely to OP – Zoe Jan 16 '18 at 14:37
  • 1
    Code-only answers are very seldom useful. Please explain how your snippet answers the question. For us all to learn. – Ole V.V. Jan 16 '18 at 15:18
0

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");
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
  • Thank you for the help.But I am still unable to open the file.I mean, it shows the loading bar forever in the Android Emulator.Please help me if you can:) – waheed abbax Jan 17 '18 at 08:39
0

Try this:

pptViewer.loadPPT(MainActivity.this,"/home/waheed/lab6.pptx");
Zoe
  • 27,060
  • 21
  • 118
  • 148
Jayesh
  • 131
  • 5