magento 1.9 custom module grid - magento-1.9

I am new to a magento 1.9. I have created the custom grid for custom module . But i didn't get the grid table
app/etc/modules/Bss_AdminGrid.xml
<?xml version="1.0"?>
<config>
<modules>
<Bss_AdminGrid>
<active>true</active>
<codePool>local</codePool>
</Bss_AdminGrid>
</modules>
</config>
app/code/local/Bss/AdminGrid/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Bss_AdminGrid>
<version>1.0.0</version>
</Bss_AdminGrid>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<bss_admingrid before="Mage_Adminhtml">Bss_AdminGrid_Adminhtml</bss_admingrid>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<admingrid>
<file>admingrid.xml</file>
</admingrid>
</updates>
</layout>
</adminhtml>
<global>
<helpers>
<admingrid>
<class>Bss_AdminGrid_Helper</class>
</admingrid>
</helpers>
<blocks>
<admingrid>
<class>Bss_AdminGrid_Block</class>
</admingrid>
</blocks>
<models>
<admingrid>
<class>Bss_AdminGrid_Model</class>
<resourceModel>admingrid_resource</resourceModel>
</admingrid>
<admingrid_resource>
<class>Bss_AdminGrid_Model_Resource</class>
<entities>
<admingrid_table>
<table>admingrid_table</table>
</admingrid_table>
</entities>
</admingrid_resource>
<!-- Resource model to create a database table -->
<admingrid_resource>
<class>Bss_AdminGrid_Model_Resource</class>
<entities>
<adgrid>
<table>admingrid_adgrid</table>
</adgrid>
</entities>
</admingrid_resource>
</models>
<resources>
<admingrid_setup>
<setup>
<module>Bss_AdminGrid</module>
</setup>
</admingrid_setup>
<connection>
<use>core_setup</use>
</connection>
<admingrid_write>
<connection>
<use>core_write</use>
</connection>
</admingrid_write>
<admingrid_read>
<connection>
<use>core_read</use>
</connection>
</admingrid_read>
</resources>
</global>
<layout>
<updates>
<admingrid>
<file>bss/admingrid.xml</file>
</admingrid>
</updates>
</layout>
</config>
app\code\local\Bss\AdminGrid\Helper\Data.php
<?php
class Bss_AdminGrid_Helper_Data extends Mage_Core_Helper_Abstract
{
}
app/code/local/Bss/AdminGrid/etc/adminhtml.xml
<?xml version="1.0"?>
<config>
<menu>
<admingrid module="admingrid" translate="title">
<title>AdminGrid</title>
<sort_order>100</sort_order>
<children>
<adgrid module="admingrid" translate="title">
<title>Manage Items</title>
<sort_order>0</sort_order>
<action>*/adgrid</action>
</adgrid>
</children>
</admingrid>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<admingrid translate="title" module="admingrid">
<title>AdminGrid</title>
<sort_order>1000</sort_order>
<children>
<admingridbackend translate="title">
<title>Manage Items</title>
</admingridbackend>
</children>
</admingrid>
</children>
</admin>
</resources>
</acl>
</config>
app\code\local\Bss\AdminGrid\Model\Adgrid.php
<?php
class Bss_AdminGrid_Model_Adgrid extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('admingrid/adgrid');
}
}
app\code\local\Bss\AdminGrid\Model\Mysql4\Adgrid.php
<?php
class Bss_AdminGrid_Model_Mysql4_Adgrid extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
$this->_init('admingrid/adgrid', 'id');
}
}
app\code\local\Bss\AdminGrid\Model\Mysql4\Adgrid\Collection.php
<?php
class Bss_AdminGrid_Model_Mysql4_Adgrid_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
protected function _construct()
{
$this->_init('admingrid/adgrid');
}
}
app\code\local\Bss\AdminGrid\Model\Resource\Adgrid.php
<?php
class Bss_AdminGrid_Model_Resource_Adgrid extends Mage_Core_Model_Resource_Db_Abstract
{
protected function _construct()
{
$this->_init('admingrid/adgrid', 'id');
}
}
app\code\local\Bss\AdminGrid\Block\Adminhtml\Adgrid.php
<?php
class Bss_AdminGrid_Block_Adminhtml_Adgrid extends Mage_Adminhtml_Block_Widget_Grid_Container {
public function __construct()
{
$this->_blockGroup = 'admingrid';
$this->_controller = 'adminhtml_adgrid';
$this->_headerText = $this->__('Admin Grid');
$this->_addButtonLabel = Mage::helper('admingrid')->__('Add Attribute Options');
parent::__construct();
}
}
app\code\local\Bss\AdminGrid\Block\Adminhtml\Adgrid\Grid.php
<?php
class Bss_AdminGrid_Block_Adminhtml_Adgrid_Grid extends Mage_Adminhtml_Block_Widget_Grid {
public function __construct()
{
parent::__construct();
$this->setDefaultSort('adminGrid_id');
$this->setId('adminGrid');
$this->setDefaultDir('asc');
$this->setSaveParametersInSession(true);
}
protected function _getCollectionClass()
{
return 'admingrid/adgrid_collection';
}
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id',
array(
'header'=> $this->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'id'
)
);
$this->addColumn('items',
array(
'header'=> $this->__('Items'),
'index' => 'items'
)
);
return parent::_prepareColumns();
}
}
app\code\local\Bss\AdminGrid\controllers\Adminhtml\AdgridController.php
<?php
class Bss_AdminGrid_Adminhtml_AdgridController extends Mage_Adminhtml_Controller_Action
{
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('admingrid/adgrid');
}
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function gridAction()
{
$this->loadLayout();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('bss_admingrid/adminhtml_adgrid_grid')->toHtml()
);
}
public function exportCsvAction()
{
$fileName = 'admingrid.csv';
$grid = $this->getLayout()->createBlock('bss_admingrid/adminhtml_adgrid_grid');
$this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
}
public function exportExcelAction()
{
$fileName = 'admingrid.xml';
$grid = $this->getLayout()->createBlock('bss_admingrid/adminhtml_adgrid_grid');
$this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
}
}
app\code\local\Bss\AdminGrid\sql\admingrid_setup\mysql4-install-1.0.0.php
<?php
$installer = $this;
$installer->startSetup();
$installer->run("
DROP TABLE IF EXISTS {$this->getTable('admingrid/adgrid')};
CREATE TABLE {$this->getTable('admingrid/adgrid')} (
`id` int(11) unsigned NOT NULL auto_increment,
`item` text NULL ,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
app\design\adminhtml\default\default\layout\admingrid.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_adgrid_index>
<reference name="content">
<block type="admingrid/adminhtml_adgrid" name="adgrid"/>
</reference>
</adminhtml_adgrid_index>
</layout>
Output what i am getting:
enter image description here
I am expecting this as my output
enter image description here
Can anyone say where i am making mistake?? Thanks in advance

protected function _prepareCollection() { $collection = Mage::getModel("admingrid/adgrid")->getCollection(); $this->setCollection($collection); return parent::_prepareCollection(); }

Related

Bar chart in javafx does not show anything

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.chart.BarChart?>
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" styleClass="mainFxmlClass" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Views.MonthlyHoursController">
<children>
<VBox alignment="CENTER" layoutX="121.0" layoutY="121.0" prefHeight="600.0" prefWidth="800.0" spacing="20.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label styleClass="header" text="Monthly Hours" />
<HBox prefHeight="292.0" prefWidth="760.0">
<children>
<BarChart fx:id="barChart" prefHeight="292.0" prefWidth="755.0">
<xAxis>
<CategoryAxis fx:id="months" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis fx:id="hoursWorked" side="LEFT" />
</yAxis>
</BarChart>
</children>
</HBox>
<HBox alignment="BOTTOM_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<Button mnemonicParsing="false" text=" Back" />
</children>
</HBox>
</children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</VBox>
</children>
</AnchorPane>
Above is my fxml file for the bar chart
package Views;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDate;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
public class MonthlyHoursController implements Initializable {
#FXML private BarChart<?, ?> barChart;
#FXML private CategoryAxis months;
#FXML private NumberAxis hoursWorked;
private XYChart.Series currentYearSeries, previousYearSeries;
#Override
public void initialize(URL arg0, ResourceBundle arg1) {
currentYearSeries = new XYChart.Series<>();
previousYearSeries = new XYChart.Series<>();
// barChart.setTitle("Hours Worked");
months.setLabel("Months");
hoursWorked.setLabel("Hours Worked");
currentYearSeries.setName(Integer.toString(LocalDate.now().getYear()));
previousYearSeries.setName(Integer.toString(LocalDate.now().getYear()-1));
try {
populateSeriesFromDB();
} catch (SQLException e) {
e.printStackTrace();
}
barChart.getData().addAll(previousYearSeries);
barChart.getData().addAll(currentYearSeries);
}
private void populateSeriesFromDB() throws SQLException {
Connection conn = null;
Statement statement = null;
ResultSet resultSet = null;
try{
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bakery?useSSL=false", "root",
"a3756421");
statement = conn.createStatement();
String sql = " Select Year(dateworked), monthname(dateworked), sum(hoursworked)" +
"From hoursworked" +
"Group by year(dateworked), month(dateworked)" +
"Order by Year(dateworked), month(dateworked);";
resultSet = statement.executeQuery(sql);
while (resultSet.next()){
if(resultSet.getInt(1)==LocalDate.now().getYear())
currentYearSeries.getData().add(new XYChart.Data(resultSet.getString(2), resultSet.getString(3)));
else if(resultSet.getInt(1)==LocalDate.now().getYear()-1)
previousYearSeries.getData().add(new XYChart.Data(resultSet.getString(2), resultSet.getString(3)));
}
}
catch (SQLException e){
System.err.println(e.getMessage());
}
finally{
if(conn !=null)
conn.close();
if (statement != null)
statement.close();
if(resultSet != null)
resultSet.close();
}
}
}
this is the controller for the fxml.
If I perform
From hoursworked
Group by Year(dateworked), month(dateworked)
Order by Year(dateworked), month(dateworked);
in workbench, it gives below:
However, when I open the fxml file, it doesnt show anything in the bar chart.
Is there something wrong with my javafx or mysql syntax?
The program itself does not give any error when it's run.
I have no idea where to even start fixing this.

Failed to create target binding for binding SelectedItem

I try to bind the selected item of a MvxListView to my property. This is my Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
layout="#layout/toolbar_actionbar" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_search_text"
local:MvxBind="Text SearchText" />
<MvxListView
android:id="#+id/category_list"
android:orientation="vertical"
android:choiceMode="singleChoice"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxItemTemplate="#layout/listitem_category"
local:MvxBind="ItemsSource Categories; SelectedItem SelectedCategory" />
</LinearLayout>
</LinearLayout>
The ItemSource here is properly bound.
ViewModel:
[ImplementPropertyChanged]
public class SelectCategoryListViewModel : AbstractCategoryListViewModel
{
/// <summary>
/// Creates an CategoryListViewModel for the usage of providing a category selection.
/// </summary>
/// <param name="categoryRepository">An instance of <see cref="IRepository{T}" /> of type category.</param>
/// <param name="dialogService">An instance of <see cref="IDialogService" /></param>
public SelectCategoryListViewModel(IRepository<Category> categoryRepository,
IDialogService dialogService) : base(categoryRepository, dialogService)
{}
public Category SelectedCategory { get; set; }
public MvxCommand DoneCommand => new MvxCommand(Done);
public MvxCommand CancelCommand => new MvxCommand(Cancel);
private void Done()
{
MessageHub.Publish(new CategorySelectedMessage(this, SelectedCategory));
Close(this);
}
private void Cancel()
{
Close(this);
}
}
Not the notify PropertyChanged is done via Fody and Categories are in the parent VM.
public class SelectCategoryListActivity : MvxFragmentCompatActivity<SelectCategoryListViewModel>
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.fragment_category_list);
SetSupportActionBar(FindViewById<Toolbar>(Resource.Id.toolbar));
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
}
...
The Warning I get is:
[0:] MvxBind:Warning: 5.11 Failed to create target binding for binding SelectedItem for SelectedCategory
Ideas?
I just came across a similar issue with a SelectedItem binding failing. The solve was to update Mvx to version 4.1.6. The reason being is that you need to register MvxAppCompatSetupHelper.FillTargetFactories, with 4.1.6 this is now done automatically.
Alternatively, you can manually register it in you setup.cs by overriding FillTargetFactories:
protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry)
{
MvxAppCompatSetupHelper.FillTargetFactories(registry);
base.FillTargetFactories(registry);
}

App unfortunately stopped Working

This is my code for MainActivity.java
Here I am creating a very basic LoginApp. When the App runs, it gives "unfortunately stopped working ERROR..."
package com.example.loginapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
EditText t1,t2;
Button b1;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1= (Button) b1.findViewById(R.id.button1);
t1=(EditText) t1.findViewById(R.id.editText1);
t2=(EditText) t2.findViewById(R.id.editText2);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public void onClick(View arg0)
{
//String user;
//user = t1.setText("user");
if (arg0.findViewById(R.id.button1)==b1)
{
if ((boolean)((t1.getText().toString()=="user")) && (t2.getText().toString()=="user"))
{
Toast.makeText(this, "Login Sucessful", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "Sorry", Toast.LENGTH_SHORT).show();
t1.setText("");
t2.setText("");
}
}
}
}
Following is code for activity_main.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:gravity="center"
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=".MainActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/editText1"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_centerVertical="true"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="115dp"
android:layout_marginTop="22dp"
android:ems="10" >
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_alignLeft="#+id/editText1"
android:ems="10"
android:inputType="numberPassword" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_marginTop="46dp"
android:layout_toRightOf="#+id/textView2"
android:clickable="true"
android:onClick="onClick"
android:text="Login" />
</RelativeLayout>
Code for AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loginapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.loginapp.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>
</application>
</manifest>
Hi please repleace the onCreate method as
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1= (Button) findViewById(R.id.button1);
t1=(EditText) findViewById(R.id.editText1);
t2=(EditText) findViewById(R.id.editText2);
}
It will helpful for you.
After modified the code it working fine for me.Please try and let me know.

GCM air extension

I'm building an air extension and the very first method to call on my extention is to check if
GCMRegistrar.checkDevice($context.getActivity());
GCMRegistrar.checkManifest($context.getActivity());
are supported and set, so wrote: CheckGcm.java
package com.doitflash.air.extensions.gcm;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREInvalidObjectException;
import com.adobe.fre.FREObject;
import com.adobe.fre.FRETypeMismatchException;
import com.adobe.fre.FREWrongThreadException;
import com.google.android.gcm.GCMConstants;
import com.google.android.gcm.GCMRegistrar;
public class CheckGcm implements FREFunction
{
private String _result;
public FREObject call(FREContext $context, FREObject[] $params)
{
//$context.dispatchStatusEventAsync("variable", "value");
try
{
GCMRegistrar.checkDevice($context.getActivity());
GCMRegistrar.checkManifest($context.getActivity());
_result = "true";
}
catch(Exception err)
{
_result = "false";
}
return as3ConvertValue(_result);
}
private FREObject as3ConvertValue(String $value)
{
try
{
return FREObject.newObject($value);
}
catch (FREWrongThreadException e)
{
return null;
}
}
}
and I setup the android manifest like this:
<manifestAdditions><![CDATA[<manifest android:installLocation="auto">
<permission android:name="air.air.com.doitflash.SampleApp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="air.air.com.doitflash.SampleApp.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application>
<activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:enabled="true"
android:exported="true"
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="air.air.com.doitflash.SampleApp" />
</intent-filter>
</receiver>
<service
android:enabled="true"
android:exported="true"
android:name="com.doitflash.air.extensions.gcm.GCMIntentService" />
</application>
</manifest>]]></manifestAdditions>
I have also setup GCMIntentService:
package com.doitflash.air.extensions.gcm;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gcm.GCMBaseIntentService;
public class GCMIntentService extends GCMBaseIntentService
{
private static final String TAG = "===GCMIntentService===";
public GCMIntentService()
{
super("000000"); // senderID
}
#Override
protected void onRegistered(Context arg0, String registrationId)
{
}
#Override
protected void onUnregistered(Context arg0, String arg1)
{
}
#Override
protected void onMessage(Context arg0, Intent arg1)
{
//Log.i(TAG, "notification title = " + arg1.getStringExtra("title"));
//Log.i(TAG, "notification message = " + arg1.getStringExtra("msg"));
//Log.i(TAG, "notification type = " + arg1.getStringExtra("type"));
//Log.i(TAG, "notification id= " + arg1.getStringExtra("id"));
}
#Override
protected void onError(Context arg0, String errorId)
{
}
#Override
protected boolean onRecoverableError(Context context, String errorId)
{
return super.onRecoverableError(context, errorId);
}
}
everything looks fine in my eyes but when I try tracing the check method in my air project, it returns null! so I know there must be something wrong with:
GCMRegistrar.checkDevice($context.getActivity());
GCMRegistrar.checkManifest($context.getActivity());
because when I remove these two lines, the trace in air returns true. just before starting to build the air extension, I built a sample GCM in java and everything was working perfectly but I don't seem to understand why the air version does not work. any ideas?
UPDATE: I used eclipse logcat to see what is happening on my phone and this may be some hints:
Could not find method com.google.android.gcm.GCMRegistrar.checkDevice, referenced from method com.doitflash.air.extensions.gcm.CheckGcm.call
unable to resolve static method 284: Lcom/google/android/gcm/GCMRegistrar;.checkDevice (Landroid/content/Context;)V

Tabs don't display on Kindle Fire

I have an Android app that uses tabs for its start menu. The tabs don't display when I port the app to a Kindle Fire. Here's the code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:isScrollContainer="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TabHost
android:id="#+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/Beginning"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/Intermediate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/Advanced"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
</ScrollView>
package com.myproject.project;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Environment;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;
import android.widget.Toast;
public class TabsTestActivity extends Activity {
/** Called when the activity is first created. */
public static final String KEY_ROWID = "_id";
public static final String KEY_NAME = "name";
public static final String KEY_LEVEL = "level";
public static final String KEY_CHART = "charted";
public String extStorageDirectory = Environment
.getExternalStorageDirectory().toString();
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PopulateDatabase();
CopyVideoFiles();
TabHost tabhost = (TabHost) findViewById(R.id.tabhost);
tabhost.setup();
TabSpec spec_beg = tabhost.newTabSpec("Beginning");
spec_beg.setContent(R.id.Beginning);
TextView txtTabInfo = new TextView(this);
txtTabInfo.setText("JUST STARTING");
Typeface font = Typeface.createFromAsset(getAssets(), "danielbd.ttf");
txtTabInfo.setTypeface(font);
txtTabInfo.setGravity(Gravity.CENTER);
txtTabInfo.setHeight(50);
txtTabInfo.setBackgroundColor(Color.parseColor("#CCDE8A"));
txtTabInfo.setTextColor(Color.parseColor("#262405"));
spec_beg.setIndicator(txtTabInfo);
TabSpec spec_int = tabhost.newTabSpec("Intermediate");
spec_int.setContent(R.id.Intermediate);
txtTabInfo = new TextView(this);
txtTabInfo.setText("GETTING THERE");
txtTabInfo.setTypeface(font);
txtTabInfo.setGravity(Gravity.CENTER);
txtTabInfo.setHeight(50);
txtTabInfo.setBackgroundColor(Color.parseColor("#CCDE8A"));
txtTabInfo.setTextColor(Color.parseColor("#262405"));
spec_int.setIndicator(txtTabInfo);
TabSpec spec_adv = tabhost.newTabSpec("Advanced");
spec_adv.setContent(R.id.Advanced);
txtTabInfo = new TextView(this);
txtTabInfo.setText("REALLY GOOD");
txtTabInfo.setTypeface(font);
txtTabInfo.setGravity(Gravity.CENTER);
txtTabInfo.setHeight(50);
txtTabInfo.setBackgroundColor(Color.parseColor("#CCDE8A"));
txtTabInfo.setTextColor(Color.parseColor("#262405"));
spec_adv.setIndicator(txtTabInfo);
// get data from database, create buttons and name them
SQLData myTable = new SQLData(this);
myTable.open();
Cursor c = myTable.getallData();
int iRow = c.getColumnIndex(KEY_ROWID);
int iName = c.getColumnIndex(KEY_NAME);
int iLevel = c.getColumnIndex(KEY_LEVEL);
// create the buttons
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
final String RowNum = c.getString(iRow);
String Name = c.getString(iName);
final String Level = c.getString(iLevel);
Button button = new Button(this);
button.setText(Name);
button.setHeight(20);
button.setTextColor(Color.BLACK);
button.setBackgroundColor(Color.parseColor("#A89E0A"));
button.setHighlightColor(Color.WHITE);
button.setTypeface(font);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent choice = new Intent(getApplicationContext
(),
com.myproject.project.myclass.class);
Bundle dataBundle = new Bundle();
dataBundle.putString("RowID", RowNum);
dataBundle.putString("Level", Level);
choice.putExtras(dataBundle);
try {
startActivity(choice);
} catch (Exception e) {
Dialog d = new Dialog(getApplicationContext());
d.setTitle("TabsTestActivity line 131");
TextView tv = new TextView(getApplicationContext());
tv.setText(e.toString());
d.setContentView(tv);
d.show();
} finally {
}
}
});
LinearLayout lbeg = (LinearLayout) findViewById(R.id.Beginning);
LinearLayout lint = (LinearLayout) findViewById(R.id.Intermediate);
LinearLayout ladv = (LinearLayout) findViewById(R.id.Advanced);
if (Level.equals("Beginning"))
lbeg.addView(button);
else if (Level.equals("Intermediate"))
lint.addView(button);
else if (Level.equals("Advanced"))
ladv.addView(button);
}
tabhost.addTab(spec_beg);
tabhost.addTab(spec_int);
tabhost.addTab(spec_adv);
myTable.close();
}}
Does anyone know why? The tabs and their contents show up fine in the emulator and on my Android phone. Thanks!
I have since learned that the Kindle Fire does not support Tabs