2011-10-07 78 views
2

我想单击图像时发生新的活动。 我已经在清单文件中写入activity android:name=.openPdf显式意图错误

,但它让我看到了一个错误: -

"android.content.ActivityNotFoundException: Unable to find explicit activity class {Parsing.this/openPdf.class}; have you declared this activity in your AndroidManifest.xml? 
" 

代码::

iv1.setOnClickListener(new View.OnClickListener() 
      { 
       public void onClick(View v) 
       { 
        // Toast.makeText(getApplicationContext(), "hello",Toast.LENGTH_SHORT).show(); 

       Intent pdf=new Intent(Parsing.this,openPdf.class); 
       startActivity(pdf); 

      } 

     }); 

回答

0

请确保你所启动的活动在同一个软件包中,然后你可以像android:name=.openPdf那样编写,否则需要使用包含完整的类名称。

+0

+0

请编辑你的答案以添加新信息而不是评论它。 –

+0

nope ....相同的错误happen.i已经在同一个包中创建了第二个活动,现在我使用完整的类名但没有效果。 – arpit

0

事实上,你在你的清单文件havnt登记活动,以便克服 附加活动标签和它的名字您的Manifest文件, 像...

<activity android:name=".openPdf" /> // "." works as a package name 
+0

nope ....同样的错误happen.i已经在同一个包中创建了第二个活动并更改了清单文件。现在我使用完整的课程名称,但没有效果。 – arpit

+0

清理你的项目,通过去项目选项卡,并发布你的清单文件 – jazz

0

而不是Parsing.this使用getApplicationContext();这可能工作。而不是手动添加android:name =“。openPdf”。在清单应用程序标签中浏览它。

干杯!